$.ajax({ url: "${ctx}/selfprogram/selfProgram/showParam?paramIds="+pmIds, type: "get", dataType:"json", success: function (data) { var obj = eval(data); var str = ""; var exParamerIds = parent.parent.$("#exParamerIds").val(); var eachParamer = exParamerIds.substring(0,exParamerIds.length-1).split(","); str = str+"<thead><tr><th style="display: none;">主键+</th><th>序号</th><th>参数名称</th><th>参数分类</th><th>单位</th><th>排序</th></tr>" +"</thead><tbody id="paramTable">"; for (var i = 0; i < eachParamer.length; i++) { /*当返回数据id与隐藏域数据一致时,将隐藏域对应的排序给页面展示*/ var index = eachParamer[i].indexOf(":"); var praId = eachParamer[i].substring(0,index); var querySort = eachParamer[i].charAt(eachParamer[i].length - 1); str = str +"<tr id="paramTr"><td id="sort">"+querySort +"</td><td style="display: none;">"+obj[i].id +"</td><td>"+obj[i].name +"</td><td>"+obj[i].typeValue +"</td><td>"+obj[i].unitValue +"</td><td><a href="#" class="up" onClick="upward(this,2)">上移</a> <a href="#" class="down" onClick="downward(this,2)">下移</a></td></tr>"; } str = str+"</tbody>"; parent.parent.$("#contentTable2").html(str); parent.parent.initTableCheckbox(parent.parent.$('#contentTable2 thead tr'),parent.parent.$('#contentTable2 tbody tr')); parent.parent.$.jBox.close(true); }
后台
public static void outResult(HttpServletResponse response, Object object) { response.setContentType("text/plain;charset=UTF-8"); response.setHeader("Cache-Control", "no-cache"); PrintWriter out = null; try { out = response.getWriter(); } catch (Exception e) { e.printStackTrace(); } String str = JsonMapper.toJsonString(object); out.print(str); out.flush(); out.close(); }
@RequiresPermissions("selfprogram:selfProgram:view") @RequestMapping(value = "showParam") public String showParam(String paramIds,HttpServletResponse response) { List<Parameters> parametersList = new ArrayList<Parameters>();
...... JsonMapper.toJsonString(parametersList); outResult(response,parametersList); return null; }