Created
August 8, 2014 04:07
-
-
Save itsmanishagarwal/7da775123a0ba64238b4 to your computer and use it in GitHub Desktop.
Corrected Spring method
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@RequestMapping(value = "/enter", method = RequestMethod.POST) | |
public String enter(HttpServletRequest request, ModelMap map, HttpSession session, | |
@ModelAttribute @Valid User user, BindingResult result) { | |
if (result.hasErrors()) { | |
logger.debug("validation error"); | |
map.addAttribute("error", result.getFieldError().getDefaultMessage()); | |
return "enter.again"; | |
} | |
try { | |
userService.create(user); | |
} catch (Exception e) { | |
logger.warn("User with email address \"" + user.getEmailAddress() + "\" Already Exists"); | |
map.addAttribute("error", "User with email address \"" + user.getEmailAddress() + "\" Already Exists"); | |
return "enter.again"; | |
} | |
return "done"; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment