时间:2021-07-01 10:21:17 帮助过:35人阅读
结果都不是,纠结了几个小时,后来经过大牛的提醒发现,原来代码还是出在服务器端,疏忽了。
@RequestMapping(value = "/searchUserList.form") @ResponseBody public void searchUserList(int page, int rows, HttpServletRequest request, HttpServletResponse response) throws IOException{ System.out.println("idcard="+idCard+"\n page="+page+"\n rows="+rows); List输出中文,这一句一定要放到response.setContentType("text/html;charset=utf-8"), response.setHeader("Cache-Control", "no-cache")后面,否则中文返回到页面是乱码 out.print(json.toString()); out.flush(); out.close(); }list = userService.findByIDCard(idCard); int totalRecord = list.size(); int totalPage = totalRecord%rows == 0 ? totalRecord/rows : (totalRecord/rows+1); int index = (page-1)*rows; int pageSize = rows; String json = "{\"total\": \""+totalPage+"\", \"page\": \""+page+"\", \"records\": \""+totalRecord+"\", \"rows\": ["; for (int i = index; i < pageSize + index && i