title: Getting java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
body: <p>Getting <code>java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute</code> error in spring 3.0. How can I resolve it?</p>
  
  <p>Below is the code for the files</p>
  
  <p><strong>index.jsp</strong></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
  pageEncoding="ISO-8859-1"%&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;html&gt;
  &lt;head&gt;
  &lt;meta http-equiv="Content-Type" content="text/html; charset=UTF-8"&gt;
  &lt;title&gt;Form handling&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
       &lt;form:form action="/emp/showEmployee" method="POST"&gt;
   &lt;table&gt;
  &lt;tbody&gt;
   &lt;tr&gt;&lt;td&gt;Employee Name: &lt;/td&gt;&lt;td&gt;&lt;form:input path="empName"/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;Employee Skill: &lt;/td&gt;&lt;td&gt;&lt;form:input path="empSkill"/&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;tr&gt;&lt;td&gt;&lt;input type="submit" value = "Submit"&gt;&lt;/td&gt;&lt;/tr&gt;
   &lt;/tbody&gt;
  &lt;/table&gt;
  &lt;/form:form&gt;
  &lt;/body&gt;
   &lt;/html&gt;
  </code></pre>
  
  <p><strong>web.xml</strong></p>
  
  <pre><code>&lt;web-app xmlns="http://java.sun.com/xml/ns/javaee"
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
    xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd"
    version="3.0"&gt;
  
  &lt;!-- Processes application requests --&gt;
  &lt;servlet&gt;
      &lt;servlet-name&gt;emp&lt;/servlet-name&gt;
      &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;            
  &lt;/servlet&gt;
  
  &lt;servlet-mapping&gt;
      &lt;servlet-name&gt;emp&lt;/servlet-name&gt;
      &lt;url-pattern&gt;/&lt;/url-pattern&gt;
  &lt;/servlet-mapping&gt;
  
  &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;/WEB-INF/views/index.jsp&lt;/welcome-file&gt;
  &lt;/welcome-file-list&gt;    
  &lt;context-param&gt;
          &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
          &lt;param-value&gt;/WEB-INF/context-config.xml&lt;/param-value&gt;
      &lt;/context-param&gt;
  &lt;listener&gt;
      &lt;listener-class&gt;org.springframework.web.context.ContextLoaderListener&lt;/listener-class&gt;
  &lt;/listener&gt;
  </code></pre>
  
  <p></p>
  
  <p><strong>context-config.xml</strong></p>
  
  <pre><code>&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"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
     xsi:schemaLocation="http://www.springframework.org/schema/beans 
                         http://www.springframework.org/schema/beans/spring-beans.xsd
                         http://www.springframework.org/schema/context 
                         http://www.springframework.org/schema/context/spring-context.xsd
                         http://www.springframework.org/schema/mvc
                         http://www.springframework.org/schema/mvc/spring-mvc.xsd"&gt;
  </code></pre>
  
  <p>
   
   
      
      
   
   </p>
  
  <p><strong>EmployeeController.java</strong></p>
  
  <pre><code> package com.springmvctut.controller;
  
   import org.springframework.stereotype.Controller;
   import org.springframework.ui.ModelMap;
   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.springmvctut.bean.EmployeeForm;
  
   @Controller
   public class EmployeeController {
  
  @RequestMapping(value = "/employee", method = RequestMethod.GET)
    public ModelAndView employee() {
      return new ModelAndView("employeeForm", "command", new EmployeeForm());
     }
  @RequestMapping(value = "/showEmployee", method = RequestMethod.POST)
  public String showEmployee(@ModelAttribute("SpringWeb")EmployeeForm employeeForm, ModelMap modelMap){
  
      modelMap.addAttribute("name", employeeForm.getEmpName());
      modelMap.addAttribute("skill", employeeForm.getEmpSkill());
      return "employeedetails";
  
  }
  
  }
  </code></pre>
  
  <p><strong>EmployeeForm.java(Bean class)</strong></p>
  
  <pre><code>package com.springmvctut.bean;
  
  public class EmployeeForm {
  
  private String empName;
  private String empSkill;
  public String getEmpName() {
      return empName;
  }
  public void setEmpName(String empName) {
      this.empName = empName;
  }
  public String getEmpSkill() {
      return empSkill;
  }
  public void setEmpSkill(String empSkill) {
      this.empSkill = empSkill;
  }
  public String toString(){
        return "Employee name-"+empName+" Employee Skill-"+empSkill;
       }
  
  }
  </code></pre>