title: Spring - same mapping to display different list
body: <p>I'm trying to use the same view to display different lists based on the param I'm passing from the button in JSP.</p>
  
  <p>what I need is: when user click on button, will call the same view but data should be display from the second list .(getPreviousYearReports())</p>
  
  <p>here's my code:</p>
  
  <pre><code>@RequestMapping(value = "/viewReports.do", method = {RequestMethod.GET , RequestMethod.POST})
  public ModelAndView viewReports( @RequestParam final Integer storeNumber,
          final HttpServletRequest request) {
      ModelAndView view = getModelAndView("viewReports");
  
      List&lt;StoreReport&gt; reportsList;
      if(request.getParameter("previous") != null ) {
          reportsList = storeReportService.getPreviousYearReports(storeNumber);
  
      } else {
          reportsList = storeReportService.getReportsByStore(storeNumber);
      }
  ....
  }
  </code></pre>
  
  <p>in my JSP. 
  I have added submit button to call the same view mapping </p>
  
  <pre><code>&lt;button id="previous" name="previous" type="submit" class="btnFwd gradient smButtonStyling"
      onClick="window.location.href='/viewReports.do?storeNumber=${storeNumber}'"&gt;
  View Previous Year Reports
  </code></pre>
  
  <p></p>