后台代码:
@RequestMapping(value="/queryComboPage") public void testComboPage(HttpServletRequest request, HttpServletResponse response) { response.setContentType("text/html;charset=utf-8"); try { PrintWriter out = response.getWriter(); int start = Integer.parseInt(request.getParameter("start")); int limit = Integer.parseInt(request.getParameter("limit")); System.err.println("start=" +start + ",limit=" + limit); //总记录数 int totalProperty = 17; String str = "{did:%d, dname:'%s'}"; StringBuffer sb = new StringBuffer("{totalProperty:"); sb.append(totalProperty).append(",root:["); int end = start + limit; if(end > totalProperty){ end = totalProperty; } for(int i = start; i < end; i++){ sb.append(String.format(str,i,"部门"+i)); if(i < end - 1){ sb.append(",");//各json对象用","隔开, 最后一个不要 } } sb.append("]}"); out.println(sb.toString()); out.flush(); out.close(); } catch (IOException e) { e.printStackTrace(); } }?