title: Neither BindingResult nor plain target object for bean name available as request attribute - Spring MVC
body: <p>I am getting this error </p>
  
  <pre><code>java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
  </code></pre>
  
  <p>This is the stack trace</p>
  
  <blockquote>
  org.apache.jasper.JasperException: java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
      org.apache.jasper.servlet.JspServletWrapper.handleJspException(JspServletWrapper.java:534)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:452)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  
  
  root cause 
  
  java.lang.IllegalStateException: Neither BindingResult nor plain target object for bean name 'command' available as request attribute
      org.springframework.web.servlet.support.BindStatus.(BindStatus.java:141)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getBindStatus(AbstractDataBoundFormElementTag.java:178)
      org.springframework.web.servlet.tags.form.AbstractDataBoundFormElementTag.getPropertyPath(AbstractDataBoundFormElementTag.java:198)
      org.springframework.web.servlet.tags.form.LabelTag.autogenerateFor(LabelTag.java:129)
      org.springframework.web.servlet.tags.form.LabelTag.resolveFor(LabelTag.java:119)
      org.springframework.web.servlet.tags.form.LabelTag.writeTagContent(LabelTag.java:89)
      org.springframework.web.servlet.tags.form.AbstractFormTag.doStartTagInternal(AbstractFormTag.java:102)
      org.springframework.web.servlet.tags.RequestContextAwareTag.doStartTag(RequestContextAwareTag.java:79)
      org.apache.jsp.student_jsp._jspx_meth_form_005flabel_005f0(student_jsp.java:182)
      org.apache.jsp.student_jsp._jspx_meth_form_005fform_005f0(student_jsp.java:117)
      org.apache.jsp.student_jsp._jspService(student_jsp.java:79)
      org.apache.jasper.runtime.HttpJspBase.service(HttpJspBase.java:70)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
      org.apache.jasper.servlet.JspServletWrapper.service(JspServletWrapper.java:419)
      org.apache.jasper.servlet.JspServlet.serviceJspFile(JspServlet.java:389)
      org.apache.jasper.servlet.JspServlet.service(JspServlet.java:333)
      javax.servlet.http.HttpServlet.service(HttpServlet.java:722)
  
  </blockquote>
  
  <p>This is my web.xml file</p>
  
  <p><code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;web-app id="WebApp_ID" version="2.4"
      xmlns="http://java.sun.com/xml/ns/j2ee" 
      xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
  
      xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee 
      http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"&gt;
  
  
      &lt;display-name&gt;Spring MVC Form Handling&lt;/display-name&gt;
      &lt;welcome-file-list&gt;
      &lt;welcome-file&gt;student.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;HelloWeb&lt;/servlet-name&gt;
          &lt;servlet-class&gt;org.springframework.web.servlet.DispatcherServlet&lt;/servlet-class&gt;
          &lt;init-param&gt;
              &lt;param-name&gt;contextConfigLocation&lt;/param-name&gt;
              &lt;param-value&gt;/WEB-INF/HelloWeb-Servlet.xml&lt;/param-value&gt;
          &lt;/init-param&gt;
          &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
      &lt;/servlet&gt;   
  
      &lt;servlet-mapping&gt;
          &lt;servlet-name&gt;HelloWeb&lt;/servlet-name&gt;
          &lt;url-pattern&gt;/&lt;/url-pattern&gt;
      &lt;/servlet-mapping&gt;
  
  &lt;/web-app&gt;
  </code></pre>
  
  <p></code></p>
  
  <p>This is my applicationContext.xml file</p>
  
  <p><code></p>
  
  <pre><code>&lt;?xml version="1.0" encoding="UTF-8"?&gt;
  &lt;beans xmlns="http://www.springframework.org/schema/beans"
     xmlns:context="http://www.springframework.org/schema/context"
     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
     xmlns:mvc="http://www.springframework.org/schema/mvc"
  
     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
     http://www.springframework.org/schema/mvc
     http://www.springframework.org/schema/mvc/spring-mvc-3.0.xsd"&gt;
  
     &lt;context:component-scan base-package="com.Prime" /&gt;
  &lt;mvc:annotation-driven/&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;/beans&gt;
  </code></pre>
  
  <p></code></p>
  
  <p>This is my student.jsp file</p>
  
  <p><code></p>
  
  <pre><code>&lt;%@ page language="java" contentType="text/html; charset=ISO-8859-1"
      pageEncoding="ISO-8859-1"%&gt;
  &lt;!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"&gt;
  &lt;%@taglib uri="http://www.springframework.org/tags/form" prefix="form"%&gt;
  &lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Spring MVC Form Handling&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  
  &lt;h2&gt;Student Information&lt;/h2&gt;
  &lt;form:form modelAttribute="SpringWeb" method="POST" action="/HelloWeb/addStudent" commandName="SpringWeb"&gt;
     &lt;table&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="name"&gt;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&gt;&lt;form:label path="age"&gt;Age&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="age" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td&gt;&lt;form:label path="id"&gt;id&lt;/form:label&gt;&lt;/td&gt;
          &lt;td&gt;&lt;form:input path="id" /&gt;&lt;/td&gt;
      &lt;/tr&gt;
      &lt;tr&gt;
          &lt;td colspan="2"&gt;
              &lt;input type="submit" value="Submit"/&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/table&gt;  
  &lt;/form:form&gt;
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p></code></p>
  
  <p>And this is my StudentController.java file</p>
  
  <p><code></p>
  
  <pre><code>package com.Prime;
  
  import org.springframework.stereotype.Controller;
  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 org.springframework.ui.ModelMap;
  
  @Controller
  public class StudentController {
  
     @RequestMapping(value = "/student", method = RequestMethod.GET)
     public ModelAndView student() {
        return new ModelAndView("/student.jsp", "SpringWeb", new Student());
     }
  
     @RequestMapping(value = "/addStudent", method = RequestMethod.POST)
     public String addStudent(@ModelAttribute("SpringWeb")Student student, 
     ModelMap model) {
        model.addAttribute("name", student.getName());
        model.addAttribute("age", student.getAge());
        model.addAttribute("id", student.getId());
  
        return "result";
     }
  }
  </code></pre>
  
  <p></code></p>
  
  <p>Can anyone help me with this error.... Thanks in advance</p>