Guest User

Untitled

a guest
Jul 11th, 2018
101
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.52 KB | None | 0 0
  1. @RequestMapping(method = POST, value = "/reg")
  2. public String registration(@ModelAttribute("userReg") @Valid User user, BindingResult bindingResult,
  3. HttpSession session) {
  4. if(bindingResult.hasErrors()) return "redirect:/reg";
  5. if (userDAO.findByLogin(user.getLogin()) == null) {
  6. userDAO.persist(user);
  7. session.setAttribute("login", user.getLogin());
  8. return "welcomepage";
  9. }
  10. return "Registration";
  11. }
  12.  
  13. org.apache.jasper.JasperException: An exception occurred processing JSP page /Registration.jsp at line 18
  14.  
  15. 15: <form:form action="/reg" method="post" modelAttribute="user">
  16. 16: <table>
  17. 17: <tr>
  18. 18: <td><form:label path="login">Login:</form:label></td>
  19. 19: <td> <form:input path="login"/> </td>
  20. 20: <td> <form:errors path="login"/></td>
  21. 21: </tr>
  22.  
  23. java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'user' available as request attribute
  24.  
  25. ...<p>
  26. <tr>
  27. <td> <form:label path="password">Password:</form:label></td>
  28. <td> <form:input path="password"/> </td>
  29. <td> <form:errors path="password"/></td>
  30. </tr>
  31. <p>
  32. <input type="submit" value="Registration">
  33. </form:form>
  34.  
  35. @RequestMapping(method = GET, value = "/reg")
  36. public ModelAndView registration() {
  37. return new ModelAndView("Registration","user",new User());
  38. }
Add Comment
Please, Sign In to add comment