Exemplo n.º 1
0
 @RequestMapping(value = "/create", method = RequestMethod.POST)
 public String save(News news, Model model) {
   news.setCreateDate(new Date());
   newsService.save(news);
   model.addAttribute("tip", "发布成功");
   return "admin/news/create";
 }
Exemplo n.º 2
0
 @RequestMapping(value = "/list", method = RequestMethod.POST)
 @ResponseBody
 public Map<String, Object> list(
     @RequestParam(value = "sEcho", defaultValue = "1") int sEcho,
     @RequestParam(value = "iDisplayStart", defaultValue = "0") int iDisplayStart,
     @RequestParam(value = "iDisplayLength", defaultValue = "10") int iDisplayLength,
     String username)
     throws ParseException {
   int pageNumber = (int) (iDisplayStart / iDisplayLength) + 1;
   int pageSize = iDisplayLength;
   Page<News> users = newsService.findAll(pageNumber, pageSize, username);
   Map<String, Object> map = new HashMap<String, Object>();
   map.put("aaData", users.getContent());
   map.put("iTotalRecords", users.getTotalElements());
   map.put("iTotalDisplayRecords", users.getTotalElements());
   map.put("sEcho", sEcho);
   return map;
 }