I am trying to switch from html form to spring form so that I can use message properties which I think is a pretty cool feature. But I have encountered error Http 500:
org.apache.jasper.JasperException: An exception occurred processing JSP page /index.jsp at line 19
18: <form:form action="example" method="post" modelAttribute="example" >
19: UserName<form:input path="email" />
20: Password<form:input path="password" />
21: </form:form>
Stacktrace:
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:568)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:465)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:334)
javax.servlet.http.HttpServlet.service(HttpServlet.java:727)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
org.springframework.web.filter.CharacterEncodingFilter.doFilterInternal(CharacterEncodingFilter.java:88)
org.springframework.web.filter.OncePerRequestFilter.doFilter(OncePerRequestFilter.java:107)
root cause
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'example' available as request attribute
I look for other threads in the forum but couldn't find the cause. Can you suggest me where I fix it? This is my controller code:
@RequestMapping(value="/example", method=RequestMethod.POST)
public String example(@ModelAttribute("example") UserAccount aUser, BindingResult result, Model model) {
model.addAttribute("example", aUser);
return "";
}