1.jsp代码如下 复制代码 代码如下: pageEncoding="UTF-8"%>String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%> Insert title here <BR> $(function(){<BR> $("#getResult").click(function(){<BR> $.ajax({<BR> type:"post",<BR> url:"<%=basePath%>jsonAction!getData.action",<BR> dataType:"json",<BR> data:{'param1':$("#param1").attr("value"),'param2':$("#param2").attr("value")},<BR> success:function(returnData){<BR> var html = "<table border='1'><tr><td>编号<td>姓名<td>描述";<BR> for(var i = 0; i < returnData.length; i++){<BR> html += "<tr><td>"+returnData[i].id+"<td>"+returnData[i].name+"<td>"+returnData[i].description+"";<BR> }<BR> $("#result").html(html);<BR> }<BR> });<BR> });<br><br> });<BR> 2.访问 action代码如下 复制代码 代码如下: public class JsonAction extends ActionSupport{ public void getData() throws IOException { HttpServletRequest req = ServletActionContext.getRequest(); String p1 = req.getParameter("param1"); String p2 = req.getParameter("param2"); HttpServletResponse rep = ServletActionContext.getResponse(); rep.setContentType("text/json;charset=utf-8"); PrintWriter pw = rep.getWriter(); String data = "[{\"id\":\"01\",\"name\":\"zhongqian\",\"description\":\""+p1+"\"},{\"id\":\"02\",\"name\":\"zhangsan\",\"description\":\""+p2+"\"}]"; pw.print(data); pw.flush(); }} 3.效果如下: