title: Getting User's Selection From ListBox in Spring MVC/JSP/Controller
body: <p>I am building my first Spring MVC application and I'm at a point where I'm a little stuck. I have a call to a database to retrieve a list of numbers(regions) and then populate them in a list box. The user should choose one of the selections and then hit the submit button. The problem is that I don't know how to capture this on the controller side. At first I thought it would have just been as easy as getting a parameter but I guess not. I don't want to build a Java class/Bean for just a number. That would seem kind of foolish. So let me share my code with you.</p>
  
  <p>JSP:</p>
  
  <pre><code>&lt;html&gt;
  &lt;head&gt;
      &lt;title&gt;Spring 3 MVC Series - Contact Manager&lt;/title&gt;
  &lt;/head&gt;
  &lt;body&gt;
  &lt;h2&gt;Branches&lt;/h2&gt;
  
  &lt;form:form method="get" action="branch.html"&gt;
      &lt;table&gt;
  
      &lt;c:if test="${not empty lists}"&gt;
  &lt;select name="regions" size="4"&gt;
  &lt;c:forEach var="listVal" items="${lists}"&gt;
  
    &lt;option&gt;${listVal} &lt;/option&gt;
  &lt;/c:forEach&gt;
  &lt;/select&gt;
  
  &lt;/c:if&gt;
  &lt;/table&gt;
  &lt;/form:form&gt;
  
   &lt;form:form method="get" action="loadbranches.html"&gt;
    &lt;c:if test="${not empty lists}"&gt; 
   &lt;select name="branches" size="4"&gt;
  &lt;c:forEach var="branchVal" items="${branches}"&gt;
  
    &lt;option&gt;${branchVal} &lt;/option&gt;
  &lt;/c:forEach&gt;
  &lt;/select&gt;
  
  &lt;/c:if&gt;
      &lt;tr&gt;
          &lt;td colspan="2"&gt;
              &lt;input type="submit" value="submit choice" /&gt;
          &lt;/td&gt;
      &lt;/tr&gt;
  &lt;/form:form&gt;
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p>CONTROLLER:</p>
  
  <pre><code>@Controller
  @SessionAttributes
  public class BranchController {
  
      @RequestMapping(value = "/loadbranches", method = RequestMethod.GET)
      public ModelAndView getBranches() 
      {
  
           //org.springframework.web.util.WebUtils.getParametersStartingWith(, prefix)
          DatabaseConnect dbCon = new DatabaseConnect();
  
           ArrayList&lt;Object&gt; branches = dbCon.loadData(USER SELECTED NUMBER I CANNOT FIGURE OUT);
  
           ModelAndView model = new ModelAndView("branch");
  
           model.addObject("branch", branches);
  
  
           return model;
      }
  
      @RequestMapping("/branch")
      public ModelAndView showRegions()
      {
  
            DatabaseConnect dbCon = new DatabaseConnect();
  
            ArrayList&lt;Object&gt; regionIDS = dbCon.loadData("regions");
  
            ModelAndView model = new ModelAndView("branch");
            model.addObject("lists", regionIDS);
  
            return model;
  
      }
  
  }
  </code></pre>
  
  <p>As you see it's not really that complicated of an application quite yet. I am working with databases and another Java class but it works perfectly. So is there any way to get the user selection from the listbox in a Request Parameter or something? Ideally I want this to happen when the user hits submit, so that's why there's a separate form tag besides the initial loading of the list of numbers (regions), if that makes sense. I've looked at different examples involving select path parameters but isn't there just an easy way to get the selection from the list box after the user hits the submit button? I would really appreciate help with this!</p>
  
  <p>Thank you!</p>