title: Spring Web MVC, @ModelAttribute and @RequestParam together
body: <p>I have a controller with a GET method written like so:</p>
  
  <pre><code>@Controller
  public class ThingController {
  
       @RequestMapping( value = "/Thing.html", method = RequestMethod.GET )
      public String editThing(@RequestParam( "thingId" ) String thingId, @ModelAttribute ThingBean thing, BindingResult result) {
          thing = &lt;some service call using thingId&gt;
          logger.debug("The thing to edit is {}", thingBean);
          return "thing/edit";
      }
  }
  </code></pre>
  
  <p>The bean is correct (getters and setters), the service call returns the correct ThingBean with the thingId, and my JSP page at thing/edit.jsp shows up.</p>
  
  <p>The JSP is:</p>
  
  <pre><code>&lt;html&gt;
  &lt;body&gt;
      &lt;h1 id="title" class="title"&gt;Edit Thing&lt;/h1&gt;
  
  &lt;form:form id="thing" modelAttribute="thing"&gt;
      &lt;form:input path="subject" id="subject" tabindex="1" /&gt;
      &lt;form:textarea path="message" /&gt;
  
  &lt;/form:form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>Yet, the JSP displays blank values for the subject and message. Yes, there are getters/setters on those properties.</p>
  
  <p>I have a very similar Controller that works just fine, except there is no @RequestParam in the signature of the GET - mapped method there.</p>
  
  <p>I've not seen anywhere in the Spring WebMVC docs that says I can't do this - why isn't it working? Why isn't the updated ModelAttribute object being bound into the JSP form?</p>
  
  <p>EDIT:</p>
  
  <p>This controller, and this same pattern for GET calls has worked many many different places -- the variable annotated with @ModelAttribute is filled in by the method then available for the JSP page to display. Why, by adding a @RequestParam annotation, does it stop?</p>
  
  <pre><code>@RequestMapping( value = "/Things.html", method = RequestMethod.GET )
  public String getThings(@ModelAttribute ThingForm thingForm, BindingResult result) {
  
      try {
          // need to get list of Things
          List&lt;Thing&gt; Things = &lt;service call that gets list of Things&gt;;
          thingForm.setThings(Things);
          logger.debug("Things are {}", Things);
  
      }
      catch (ResourceNotFoundException e) {
          return "error";
      }
  
      logger.debug("Thing list loading - end");
  
      // Go to jsp
      return "thing/list";
  }
  </code></pre>