/** Ajax请求校验loginName是否唯一。 */ @RequestMapping(value = "checkLoginName") @ResponseBody public String checkLoginName(@RequestParam("loginName") String loginName) { if (accountService.findUserByLoginName(loginName) == null) { return "true"; } else { return "false"; } }
@RequestMapping(method = RequestMethod.POST) public String register(@Valid User user, RedirectAttributes redirectAttributes) { accountService.registerUser(user); redirectAttributes.addFlashAttribute("username", user.getLoginName()); return "redirect:/login"; }