title: Neither BindingResult nor plain target object for bean name 'userDomain' available as request attribute
body: <p>I am trying to learn Spring MVC and I am facing a problem which seems to me a common one. My hello.jsp is:</p>
  
  <pre><code> &lt;form:form commandName="userDomain" method="post" action="hello.jsp"&gt;
    &lt;table&gt;
     &lt;tr&gt;
      &lt;td&gt;&lt;form:label path="userDomain.emailId"&gt;First Name&lt;/form:label&gt;&lt;/td&gt;
      &lt;td&gt;&lt;form:input path="userDomain.emailId" /&gt;&lt;/td&gt; 
    &lt;/tr&gt;
  
   &lt;/form:form&gt;
  </code></pre>
  
  <p>And controller is :</p>
  
  <pre><code> @Controller
  public class HelloWorldController {
  
  
  
   @RequestMapping(value = "/hello", method = RequestMethod.GET)
   public String hi(@ModelAttribute("userDomain") UserDomain userDomain, BindingResult      result) {
  
  
  return "hello";
   }
  
  }
  </code></pre>
  
  <p>UserDomain is :</p>
  
  <pre><code> public class UserDomain {
  
  private long userId;
  private String name;
  private String emailId;
  private int numberOfFeedsUsed;
  private String password;
  private String rePassword;
  
      setters and getters..
  
    }
  </code></pre>
  
  <p>The code is simple but the error I am facing is:</p>
  
  <p><em>SEVERE: Servlet.service() for servlet [jsp] in context with path [/ChatBooster] threw exception [java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'userDomain' available as request attribute] with root cause
  java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'userDomain' 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)</em></p>
  
  <p>I have searched in internet but I am just not able to resolve it. Can anyone help me out here?</p>
  
  <p><strong>Edit 1: Even this one is not working.</strong> </p>
  
  <p>hello.jsp:</p>
  
  <pre><code>    &lt;form:form modelAttribute="userDomain" method="post" action="hello"&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:label path="emailId"&gt;First Name&lt;/form:label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:input path="emailId" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td&gt;&lt;form:label path="name"&gt;Last Name&lt;/form:label&gt;&lt;/td&gt;
              &lt;td&gt;&lt;form:input path="name" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
  
  
          &lt;tr&gt;
              &lt;td colspan="2"&gt;&lt;input type="submit" value="Go" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>HelloWorldController:</p>
  
  <pre><code>        @Controller
    public class HelloWorldController {
  
    @RequestMapping("/")
    public String hello() {
     return "hello";
    }
  
   @RequestMapping(value = "/hello", method = RequestMethod.POST)
    public ModelAndView hi() {
    // String message = "Hi " + name + "!";
  
    ModelAndView mav = new ModelAndView("hello");
      mav.addObject("userDomain",new UserDomain());
      return mav;
    }
  
    @ModelAttribute("userDomain")
    public UserDomain getUserDomain(){
    return new UserDomain();
      }
  
   }
  </code></pre>
  
  <p>web.xml:</p>
  
  <pre><code>  &lt;?xml version="1.0" encoding="UTF-8"?&gt;
       &lt;web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  xmlns="http://java.sun.com/xml/ns/javaee"
  xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
  id="WebApp_ID" version="2.5"&gt;
  &lt;display-name&gt;Spring Hello World&lt;/display-name&gt;
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;hello.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;
  
  &lt;listener&gt;
     &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
     &lt;/listener&gt;
  
  &lt;servlet&gt;
      &lt;servlet-name&gt;chatbooster&lt;/servlet-name&gt;
      &lt;servlet-class&gt;
          org.springframework.web.servlet.DispatcherServlet
      &lt;/servlet-class&gt;
  
      &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
  &lt;/servlet&gt;
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;chatbooster&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  &lt;context-param&gt;
  &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
  &lt;param-value&gt;/WEB-INF/chatbooster-servlet.xml&lt;/param-value&gt;
     &lt;/context-param&gt;
     &lt;/web-app&gt;
  </code></pre>
  
  <p>chatbooster-servlet.xml:</p>
  
  <pre><code>     &lt;?xml version="1.0" encoding="UTF-8"?&gt;
   &lt;beans x lns="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.controller" /&gt;
  
  &lt;bean id="viewResolver"
      class="org.springframework.web.servlet.view.UrlBasedViewResolver"&gt;
      &lt;property name="viewClass"
          value="org.springframework.web.servlet.view.JstlView" /&gt;
      &lt;property name="prefix" value="/WebContent/" /&gt;
      &lt;property name="suffix" value=".jsp" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p></p>