title: Usage Of Model and @ModelAttribute in Spring MVC
body: <p>I am new to Spring MVC and trying to convert a Struts 2 Application to Spring MVC.
  Now there are so many options to handle request parameters and setting data to be rendered on.<br>
       Let me explain by following code:</p>
  
  <pre><code>    @RequestMapping("/sales"
      public Class SalesController{
            @AutoWired 
            ISaleService saleService;
            ...
                 ///getters and setters for service instance.omitted for brevity
            ...
            @RequestMapping("/")
            public String viewRoles(@ModelAttribute SaleBean saleBean,
            Map&lt;String,Object&gt; model){
               List&lt;Sale&gt; sales = getSaleService().getAllSales();
               model.put("sales",sales); //Option 1 to render sales on jsp form
  
               SaleBean saleBean = new SaleBean();
               saleBean.setSales(sales); //option 2 to render sales on jsp form
               model.put("saleBean",saleBean)   
            } 
      }
  </code></pre>
  
  <p>In above example I have shown two options which both work fine and I can render sales info on JSP.Also I have command name as "saleBean" on my form.</p>
  
  <p>1.Is Model parameter which is usually used to put data on outgoing response so that is can be rendered on JSP really needed when I am using @ModelAttribute as a second parameter?  </p>
  
  <p>2.Do I need to explicitly instantiate SaleBean class in Option 2 of my code? Will spring instantiate it if its already null?</p>
  
  <p>3.Do I need to put saleBean into model explicitly?from spring docs it seems @Modelattribute  object is also put  on model implicitly.</p>