@RequestMapping(value = "adduser.htm", method = RequestMethod.POST) public String registerUser(@ModelAttribute("RegisterUser") User user, Model model) { regdao.addUser( regdao.maxKey("User", "user_id") + 1, user.getUsername(), user.getFirst_name(), user.getLast_name(), user.getProfile_pic(), user.getEmail(), user.getPassword()); return "Register"; }
@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; }