Last active
August 29, 2015 14:05
-
-
Save itsmanishagarwal/c88429ab435e728e517e to your computer and use it in GitHub Desktop.
SpringController
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(@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