Skip to content

Instantly share code, notes, and snippets.

@itsmanishagarwal
Last active August 29, 2015 14:05
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save itsmanishagarwal/c88429ab435e728e517e to your computer and use it in GitHub Desktop.
Save itsmanishagarwal/c88429ab435e728e517e to your computer and use it in GitHub Desktop.
SpringController
@RequestMapping(value = "/enter", method = RequestMethod.POST)
public String enter(@ModelAttribute @Valid User user, HttpServletRequest request, ModelMap map, HttpSession session,
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