当前位置: 代码迷 >> Web前端 >> Ext学习是8_ComboBox3跟分2
  详细解决方案

Ext学习是8_ComboBox3跟分2

热度:139   发布时间:2012-09-10 11:02:33.0
Ext学习是8_ComboBox3和分2

后台代码:

    @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();
		}
    	
    }
?
  相关解决方案