@RequestMapping(value = "/saveUser", method = RequestMethod.POST) public String saveUser( HttpServletRequest request, ModelMap modelMap, @Valid @ModelAttribute UserFormBean userFormBean, BindingResult result, @RequestParam(required = false, value = "cancel") String isCancel) { if (isCancel != null) { modelMap.put( "message", messageSource.getMessage("ActionCanceled", null, request.getLocale())); return "/home"; } if (!userService.isLoginFree(userFormBean.getUser().getLogin())) { FieldError error = new FieldError( "userFormBean", "user.login", messageSource.getMessage("UnUniq.userFormBean.user.login")); result.addError(error); } if (!userFormBean.getUser().getPassword().equals(userFormBean.getRepeatedPassword())) { result.addError( new FieldError( "userFormBean", "repeatedPassword", messageSource.getMessage("Size.userFormBean.repeatedPassword"))); } if (result.hasErrors()) { return "/auth/signup"; } if (userFormBean.getUser().getPassword().equals(userFormBean.getRepeatedPassword())) { userService.create(userFormBean.getUser()); return "/auth/welcome"; } else { modelMap.put( "message", messageSource.getMessage("message.RegistrationError", null, request.getLocale())); return "/auth/signup"; } }
@RequestMapping("/isLoginFree") // ajax �� jquery validation plugin @ResponseBody public String checkIsFree(@RequestParam String login4test) { return userService.isLoginFree(login4test) ? "true" : "false"; }