@RequestMapping( value = "/search/{name}/{value}.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object search( @RequestParam(value = "page", required = true, defaultValue = "1") int page, @RequestParam(value = "rows", required = true, defaultValue = "30") int rows, @PathVariable String name, @PathVariable String value) { if (value == null || value.trim().isEmpty()) { return null; } if ("userName".equals(name)) { PageBean<User> pageBean = userService.getUserByName(value); if (pageBean.getTotal() == 0) { Map<String, Integer> map = new HashMap<String, Integer>(); map.put("rows", 0); map.put("total", 0); map.put("page", 1); return map; } else { return pageBean; } } return "[]"; }
@RequestMapping( value = "/userlist.jsn", method = {RequestMethod.POST, RequestMethod.GET}) @ResponseBody public Object getUserList( HttpServletRequest request, HttpServletResponse response, @RequestParam(value = "page", required = true, defaultValue = "1") int page, @RequestParam(value = "rows", required = true, defaultValue = "30") int rows) { PageBean<User> pageBean = userService.getUsersList(page, rows); if (pageBean.getTotal() == 0) { Map<String, Integer> map = new HashMap<String, Integer>(); map.put("rows", 0); map.put("total", 0); map.put("page", 1); return map; } else { return pageBean; } }