title: I want to get the form data set in a pojo in my controller using spring 3, as like struts1.2 approach
body: <p>I have login.jsp as my welcome page/home page. Like struts1.2 approach I want data from my login.jsp(username and password) to be set in a pojo(LoginForm) and I need to access username and password from pojo in my Controller.</p>
  
  <p><strong>login.jsp</strong> </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.2.1 MVC Series&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
     &lt;br&gt;&lt;div align='center'&gt; &lt;h2&gt;Welcome to Spring MCV 3.2 Example. &lt;/h2&gt;&lt;br&gt; &lt;/div&gt;
     &lt;br/&gt;
     &lt;form:form method="post" action="login.do" modelAttribute="req"&gt;
  &lt;label for="UserName :"&gt;&lt;/label&gt; &lt;form:input path="name"/&gt;
  &lt;label for="Password :"/&gt; &lt;form:password path="password"/&gt;
  &lt;input name="submit" type="submit"/&gt;
     &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>LoginForm pojo class</strong></p>
  
  <pre><code>public class LoginForm {
  private String name;
  private String password;
  public String getName() {
      return name;
  }
  public void setName(String name) {      
      this.name = name;
  }
  public String getPassword() {
      return password;
  }
  public void setPassword(String password) {
      this.password = password;
  }
  }
  </code></pre>
  
  <p><strong>LoginController</strong></p>
  
  <pre><code>import org.springframework.stereotype.Controller;
  import org.springframework.validation.BindingResult;
  import org.springframework.web.bind.annotation.ModelAttribute;
  import org.springframework.web.bind.annotation.RequestMapping;
  import org.springframework.web.bind.annotation.RequestMethod;
  import org.springframework.web.servlet.ModelAndView;
  import com.spring3.bean.LoginForm;
  @Controller
  
  @RequestMapping("/login")
  public class LoginController {
  @RequestMapping(method = RequestMethod.POST)
  public ModelAndView userLogin(@ModelAttribute("req") LoginForm login,BindingResult result)
  {
      System.out.println("Inside LoginController...");
      return new ModelAndView("welcome","req",new LoginForm());
  }
  }
  </code></pre>
  
  <p>web.xml and dispatcher-servlet.xml file contains appropriate mappings.</p>
  
  <p>I am getting the below error.</p>
  
  <pre><code>"java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean     name 'req' available as request attribute
  "
  </code></pre>
  
  <p>My requiremnet is as in struts1.2 we get data in Action form from jsp same way how to do in spring 3, as it is a migration project.</p>