@RequestMapping(value = "/add", method = RequestMethod.POST)
 public JSONObject add(@ModelAttribute("user") User user) {
   JSONObject json = new JSONObject();
   try {
     user.setPassword(PwdUtil.md5(user.getUsername() + user.getPassword()));
     userBiz.save(user);
     json.put("err", 0);
     json.put("msg", "保存成功,成功后的ID为:" + user.getId());
   } catch (Exception e) {
     json.put("err", 1);
     json.put("msg", "保存失败!");
     Constans.LOG.error(e);
   }
   return json;
 }
示例#2
0
 @RequestMapping("chat")
 public String view(ModelMap model, HttpServletRequest request) throws Exception {
   User loginUser = this.getLoginUser(request.getSession());
   model.addAttribute("key", loginUser == null ? this.getIp(request) : loginUser.getId());
   return "chat/view";
 }