Note that there are some explanatory texts on larger screens.

plurals
  1. POjava.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute with root cause
    primarykey
    data
    text
    <p>I am new to spring , i am trying an example in spring MVC, but i am getting the mentioned error ,please check my code and help me to resolve the issue. I tried in different URL mappings (like beanNameUrlMapping ,simpleUrlMapping ) but unable to resolve the issue, please let me know root cause for this issue and steps to resolve the issue</p> <p>Thanks in Advance</p> <p><strong>My code</strong></p> <p>In this example i am just entering registration details in a jSP and want to show the details in once user details once registration is done.</p> <p>My jsp page to enter the details<br> Register.jsp</p> <pre><code>&lt;%@ taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt; &lt;html&gt; &lt;head&gt; &lt;title&gt;Spring 3 MVC Series - Contact Manager&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form:form method="post" action="addContact.html" commandName="User" &gt; &lt;table&gt; &lt;tr&gt; &lt;td&gt;&lt;form:label path="firstname"&gt;First Name&lt;/form:label&gt;&lt;/td&gt; &lt;td&gt;&lt;form:input path="firstname" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;form:label path="lastname"&gt;Last Name&lt;/form:label&gt;&lt;/td&gt; &lt;td&gt;&lt;form:input path="lastname" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;form:label path="email"&gt;Email&lt;/form:label&gt;&lt;/td&gt; &lt;td&gt;&lt;form:input path="email" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;form:label path="telephone"&gt;Telephone&lt;/form:label&gt;&lt;/td&gt; &lt;td&gt;&lt;form:input path="telephone" /&gt;&lt;/td&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td colspan="2"&gt; &lt;input type="submit" value="Add Contact"/&gt; &lt;/td&gt; &lt;/tr&gt; &lt;/table&gt; &lt;/form:form&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>In config file mapping the request to the controller config.xml file</p> <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt; &lt;beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd"&gt; &lt;context:component-scan base-package="com.mys" /&gt; &lt;bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"&gt; &lt;property name="prefix" value="/WEB-INF/jsp/" /&gt; &lt;property name="suffix" value=".jsp" /&gt; &lt;/bean&gt; &lt;bean id="userService" class="com.mys.services.UserServiceImpl" /&gt; &lt;bean name="/addContact.html" class="com.mys.login.RegistrationController" p:userService-ref="userService" p:formView="Register" p:successView="success" /&gt; &lt;/beans&gt; </code></pre> <p>My controller class</p> <pre><code>import com.formbean.User; import com.mys.services.UserService; @SuppressWarnings("deprecation") public class RegistrationController extends SimpleFormController { private UserService userService; public RegistrationController() { setCommandClass(User.class); setCommandName("user"); } public void setUserService(UserService userService) { this.userService = userService; } @Override protected ModelAndView onSubmit(Object command) throws Exception { User user = (User) command; userService.add(user); return new ModelAndView("success", "user", user); } } Form bean User.java package com.formbean; public class User { private String firstname; private String lastname; private String email; private String telephone; //setters , getter () } package com.mys.services; import com.formbean.User; public class UserServiceImpl implements UserService { @Override public void add(User user) { // TODO Auto-generated method stub System.out.println("user added successfully"); } } </code></pre> <p>This is the issue i am getting </p> <p>SEVERE: Neither BindingResult nor plain target object for bean name 'User' available as request attribute java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute at org.springframework.web.servlet.support.BindStatus.(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.LabelTag.autogenerateFor(LabelTag.java:129) at org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:119) at org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:89) 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.Register_jsp._jspx_meth_form_005flabel_005f0(Register_jsp.java:188) at org.apache.jsp.Register_jsp._jspx_meth_form_005fform_005f0(Register_jsp.java:112) at org.apache.jsp.Register_jsp._jspService(Register_jsp.java:71) at org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419) at org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:390) at org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333) at javax.servlet.http.HttpServlet.service(HttpServlet.java:722) at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304) at org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210) at org.apache.catalina.core.StandardWrapperValve.invoke(StandardWrapperValve.java:240) at org.apache.catalina.core.StandardContextValve.invoke(StandardContextValve.java:164) at org.apache.catalina.authenticator.AuthenticatorBase.invoke(AuthenticatorBase.java:462) at org.apache.catalina.core.StandardHostValve.invoke(StandardHostValve.java:164) at org.apache.catalina.valves.ErrorReportValve.invoke(ErrorReportValve.java:100) at org.apache.catalina.valves.AccessLogValve.invoke(AccessLogValve.java:563) at org.apache.catalina.core.StandardEngineValve.invoke(StandardEngineValve.java:118) at org.apache.catalina.connector.CoyoteAdapter.service(CoyoteAdapter.java:399) at org.apache.coyote.http11.Http11Processor.process(Http11Processor.java:317) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:204) at org.apache.coyote.http11.Http11Protocol$Http11ConnectionHandler.process(Http11Protocol.java:182) at org.apache.tomcat.util.net.JIoEndpoint$SocketProcessor.run(JIoEndpoint.java:311) at java.util.concurrent.ThreadPoolExecutor$Worker.runTask(Unknown Source) at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) at java.lang.Thread.run(Unknown Source) Sep 4, 2013 11:52:13 PM org.apache.catalina.core.StandardWrapperValve invoke SEVERE: Servlet.service() for servlet [jsp] in context with path [/MysteryShopping] threw exception [java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute] with root cause java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'User' available as request attribute at org.springframework.web.servlet.support.BindStatus.(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.LabelTag.autogenerateFor(LabelTag.java:129) at org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:119)</p>
    singulars
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload