title: Spring MVC: How to retrieve data apart from the Model submitted to a view
body: <p>I have the following requirement. I submit a Model object to a view as follows...</p>
  
  <pre><code>@RequestMapping(value ="/addItem", method = RequestMethod.GET)
       public ModelAndView showContacts() {           
           ModelAndView modelAndView = new ModelAndView("addItem", "command", new Item());
           return modelAndView;
       }
  </code></pre>
  
  <p>But on post, I need to retrieve a value apart from the "Item" object (model) that is returned to me. I can't have this variable be a part of the Item model object because it does not belong there. But I need it returned in order to act on that value. How can I get about doing this ?</p>
  
  <p>I.e. In my JSP file, I have the following fields...</p>
  
  <pre><code>&lt;form:input type="text" path="val1"/&gt;
  &lt;form:input type="text" path="val2"/&gt;
  &lt;form:input type="text" path="val3"/&gt;
  </code></pre>
  
  <p>Out of the above, only fields val1 and val2 have mappings to the Item object, where as val3 does not. Nevertheless, I need the value of val3 passed back to my controller as well. The code I have right now to handle the POST is as follows, but I can't figure out how to get the value for val3. The code does not compile right now because it says that there is no field or appropriate getter method in the Item class for val3.</p>
  
  <pre><code>@RequestMapping(value = "/postItem", method = RequestMethod.POST)
      public String postItem(@ModelAttribute("item") Item item , BindingResult result) {
          logger.info("Post Item:");
          return "home";
      }
  </code></pre>
  
  <p>How can I modify the above code to suite my requirement ? </p>
  
  <p>Some guidance on this matter will be highly appreciated.</p>