Programmers learn & share
0 votes
27 views

Problem :

I am very new to Spring 3's annotation and I am getting the exception.

Below is my form jsp code:

 <form:form method="POST" action="login.htm" modelAttribute="login">

  ....

  <form:input path="email" size="30" />

  ....

And following is the shameful exception I am getting whenever I try to load my landing jsp page:

SEVERE: Neither BindingResult nor plain target object for bean name 'login' available as request attribute

java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'login' available as request attribute

 at org.springframework.web.servlet.support.BindStatus.<init>(BindStatus.java:141)

 at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:174)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:194)

 at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getName(AbstractDataBoundFormElementTag.java:160)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.autogenerateId(AbstractDataBoundFormElementTag.java:147)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.resolveId(AbstractDataBoundFormElementTag.java:138)

at org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.writeDefaultAttributes(AbstractDataBoundFormElementTag.java:122)

at org.springframework.web.servlet.tags.form.AbstractHtmlElementTag.writeDefaultAttributes(AbstractHtmlElementTag.java:408)

at org.springframework.web.servlet.tags.form.InputTag.writeTagContent(InputTag.java:140)

at org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)

at org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)

at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_input_0(landing_jsp.java from :208)

at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspx_meth_form_form_0(landing_jsp.java from :164)

at org.apache.jsp.WEB_002dINF.jsp.landing_jsp._jspService(landing_jsp.java from :107)

at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:111)

at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

    at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:403)

    at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:492)

    at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:378)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

    at org.apache.catalina.core.ApplicationDispatcher.doInvoke(ApplicationDispatcher.java:787)

    at org.apache.catalina.core.ApplicationDispatcher.invoke(ApplicationDispatcher.java:649)

    at org.apache.catalina.core.ApplicationDispatcher.processRequest(ApplicationDispatcher.java:483)

    at org.apache.catalina.core.ApplicationDispatcher.doDispatch(ApplicationDispatcher.java:454)

    at org.apache.catalina.core.ApplicationDispatcher.dispatch(ApplicationDispatcher.java:350)

    at org.apache.catalina.core.ApplicationDispatcher.forward(ApplicationDispatcher.java:300)

    at org.springframework.web.servlet.view.InternalResourceView.renderMergedOutputModel(InternalResourceView.java:238)

    at org.springframework.web.servlet.view.AbstractView.render(AbstractView.java:250)

    at org.springframework.web.servlet.DispatcherServlet.render(DispatcherServlet.java:1047)

    at org.springframework.web.servlet.DispatcherServlet.doDispatch(DispatcherServlet.java:817)

    at org.springframework.web.servlet.DispatcherServlet.doService(DispatcherServlet.java:719)

    at org.springframework.web.servlet.FrameworkServlet.processRequest(FrameworkServlet.java:669)

    at org.springframework.web.servlet.FrameworkServlet.doGet(FrameworkServlet.java:574)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:734)

    at javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

    at org.apache.catalina.core.StandardWrapper.service(StandardWrapper.java:1539)

    at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:281)

    at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:175)

    at org.apache.catalina.core.StandardPipeline.doInvoke(StandardPipeline.java:655)

    at org.apache.catalina.core.StandardPipeline.invoke(StandardPipeline.java:595)

    at com.sun.enterprise.web.WebPipeline.invoke(WebPipeline.java:98)

    at com.sun.enterprise.web.PESessionLockingStandardPipeline.invoke(PESessionLockingStandardPipeline.java:91)

    at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:162)

    at org.apache.catalina.connector.CoyoteAdapter.doService(CoyoteAdapter.java:330)

    at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:231)

    at com.sun.enterprise.v3.services.impl.ContainerMapper.service(ContainerMapper.java:174)

    at com.sun.grizzly.http.ProcessorTask.invokeAdapter(ProcessorTask.java:828)

    at com.sun.grizzly.http.ProcessorTask.doProcess(ProcessorTask.java:725)

    at com.sun.grizzly.http.ProcessorTask.process(ProcessorTask.java:1019)

    at com.sun.grizzly.http.DefaultProtocolFilter.execute(DefaultProtocolFilter.java:225)

    at com.sun.grizzly.DefaultProtocolChain.executeProtocolFilter(DefaultProtocolChain.java:137)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:104)

    at com.sun.grizzly.DefaultProtocolChain.execute(DefaultProtocolChain.java:90)

    at com.sun.grizzly.http.HttpProtocolChain.execute(HttpProtocolChain.java:79)

    at com.sun.grizzly.ProtocolChainContextTask.doCall(ProtocolChainContextTask.java:54)

    at com.sun.grizzly.SelectionKeyContextTask.call(SelectionKeyContextTask.java:59)

    at com.sun.grizzly.ContextTask.run(ContextTask.java:71)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.doWork(AbstractThreadPool.java:532)

    at com.sun.grizzly.util.AbstractThreadPool$Worker.run(AbstractThreadPool.java:513)

    at java.lang.Thread.run(Thread.java:680)

by (7.5k points)   | 27 views

1 Answer

0 votes

Solution :

To begin with you need to add the login object as an attribute of the model in the controller:

model.addAttribute("login", new Login());

Like following:

@RequestMapping(value = "/", method = RequestMethod.GET)

public String displayLogin(Model model) {

model.addAttribute("login", new Login());

return "login";

}

by (36.1k points)  
2,245 questions
2,807 answers
60 comments
241 users