Hello!
I have a pretty nasty and frustrating problem with a
Maven Web Application, holding me back for some time.
Apparently, from my previous google searches, this is a common Spring MVC error, but i am not able to find the solution i need among the ones offered on the internet so far. Note that i am a beginner in Spring and in MVC concepts in general.
I have a web application which is supposed to manage a building administration (inhabitants, rent calculations, etc). I use Spring MVC, Hibernate,
Java 1.8,
Tomcat 8 server container, and SQL Server 2014.
Firstly, this is my POJO for the bulding residents, a type called Inhabitant:
This is my dispatcher-servlet.xml:
This is my web.xml:
This is my
jsp registration form, which should map to the Inhabitant object:
And finally, the controller class, which should effectively map the data from the jsp form with the java entity, Inhabitant:
Now, this is the error i get whenever i try to run my application on the server:
message java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute
description The server encountered an internal error that prevented it from fulfilling this request.
exception
org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute
org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:555)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:471)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
root cause
java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'inhabitant' available as request attribute
org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:144)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:168)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:188)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:154)
org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:117)
org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:422)
org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:142)
org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:84)
org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:80)
org.apache.jsp.login.index_jsp._jspx_meth_form_005finput_005f0(index_jsp.java:322)
org.apache.jsp.login.index_jsp._jspx_meth_form_005fform_005f0(index_jsp.java:216)
org.apache.jsp.login.index_jsp._jspService(index_jsp.java:148)
org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:438)
org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:396)
org.apache.jasper.servlet.JspServlet.service(JspServlet.java:340)
javax.servlet.http.HttpServlet.service(HttpServlet.java:729)
org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:52)
I have tried a thousand things, but i just can't get it to work. So, please, can someone point out what i'm doing wrong? How can i correctly build the java object based on the information from the jsp form?
Thanks in advance!