title: Spring MVC Neither BindingResult nor plain target object for bean name
body: <p>For some reason I cannot seem to fix this issue, even after looking at multiple examples on here.</p>
  
  <p>I am trying to handle a form using Spring 3 MVC, but I am getting the following error:</p>
  
  <pre><code> Neither BindingResult nor plain target object for bean name 'reverseString' available as request attribute
  </code></pre>
  
  <p>So I am kind of getting what is the problem here, but I failed to solve it. Here is the method in my </p>
  
  <p>ReverseController class which extends SimpleFormController:</p>
  
  <pre><code>protected ModelAndView onSubmit(HttpServletRequest request,
          HttpServletResponse response, Object command, BindException errors)
          throws Exception {
      ReverseString revString = (ReverseString) command;
      ModelAndView mav = new ModelAndView();
      ModelMap map = new ModelMap();
      map.addAttribute("reverseString", revString);
      mav.addAllObjects(map);
      return mav;
  }
  </code></pre>
  
  <p>My app-servlet.xml defines the controller as follows:</p>
  
  <pre><code>&lt;bean name="/reverse.app" class="ReverseController"&gt;
      &lt;property name="commandName" value="reverseString"&gt;&lt;/property&gt;
      &lt;property name="commandClass" value="ReverseString" /&gt;
      &lt;property name="successView" value="reverseResult" /&gt;
      &lt;property name="formView" value="reverse" /&gt;
  &lt;/bean&gt;
  </code></pre>
  
  <p>This is the form in my reverse.jsp:</p>
  
  <pre><code>&lt;form:form method="POST" modelAttribute="reverseString" action="handleForm"&gt;
  &lt;form:errors path="*" cssClass="errorblock" element="div" /&gt;
      &lt;table&gt;
          &lt;tr&gt;
              &lt;td&gt;String to be reversed:&lt;/td&gt;
              &lt;td&gt;&lt;form:input path="stringToReverse" /&gt;
              &lt;/td&gt;
              &lt;td&gt;&lt;form:errors path="stringToReverse" cssClass="error" /&gt;
              &lt;/td&gt;
          &lt;/tr&gt;
          &lt;tr&gt;
              &lt;td colspan="3"&gt;&lt;input type="submit" /&gt;&lt;/td&gt;
          &lt;/tr&gt;
      &lt;/table&gt;
  &lt;/form:form&gt;
  </code></pre>
  
  <p>And this is what is being defined in my web.xml:</p>
  
  <pre><code> &lt;web-app&gt;
    &lt;display-name&gt;Spring Reverse String&lt;/display-name&gt;      
    &lt;welcome-file-list&gt;
        &lt;welcome-file&gt;reverse.jsp&lt;/welcome-file&gt;
    &lt;/welcome-file-list&gt;
    &lt;servlet&gt;
        &lt;servlet-name&gt;app&lt;/servlet-name&gt;
        &lt;servlet-class&gt;Dispatcher&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;app&lt;/servlet-name&gt;
          &lt;url-pattern&gt;*.app&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/app-servlet.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;
  &lt;/web-app&gt;
  </code></pre>
  
  <p>And finally, this is my ReverseString object:</p>
  
  <pre><code>public class ReverseString {
  
  public String stringToReverse;
  public String reversedString;
  
  public ReverseString(String rawString) {
      this.reversedString = reverseString(stringToReverse);
  }
  
  public String getStringToReverse() {
      return stringToReverse;
  }
  
  public void setStringToReverse(String stringToReverse) {
      this.stringToReverse = stringToReverse;
  }
  
  public String reverseString(String rawString) {
      if(rawString == null || rawString.length() &lt;= 1) return rawString;
      return reverseString(rawString.substring(1)) + rawString.charAt(0);
  }
  </code></pre>
  
  <p>}</p>