title: How to get back list for drop down as @ModelAttribute for Spring mvc Post?
body: <p>I have the following ViewModel that sets a list of items to display in my drop down.</p>
  
  <p>myController/Index</p>
  
  <pre><code>// set view model list of items to populate in drop down...viewModel contains listItems as   
     List&lt;String&gt;
  viewModel.setlistitems(//list retrieved 3rd party);
  // add view model to model to display items in drop down list viewModel.getlistitems() returns List&lt;String&gt;
  model.addAttribute("viewModel", viewModel);  
  </code></pre>
  
  <p>Then I have the drop down list in my index.jsp which populates the list fine:</p>
  
  <pre><code> &lt;form class="form-horizontal" action="myController/indexSubmit" method="post"&gt;
      &lt;select name="selectList" class="form-control" placeholder=".input-medium" height&gt;
          &lt;c:forEach items="${viewModel.getlistitems()}" var="item" varStatus="count"&gt; 
              &lt;option value="${count.index}"&gt;${item }&lt;/option&gt;
          &lt;/c:forEach&gt;
      &lt;/select&gt;   
      &lt;button type="submit" class="btn btn-primary btn-medium"&gt;Submit&lt;/button&gt;   
  &lt;/form&gt;  
  </code></pre>
  
  <p>Submit posts back and I get the index of the selected drop down just fine within "selectList".  However, when i try to get the list items from my view model it's null?  </p>
  
  <pre><code>@RequestMapping(value="indexSubmit", method = RequestMethod.POST)
    public String indexSubmit( @RequestParam String selectList, 
        @ModelAttribute("viewModel") ViewModel viewModel, ModelMap model) {
  
      System.out.println("Selected Item: " + selectList);  // returns the index fine
      System.out.println("Items: " + viewModel.getlistitems());  // returns NULL!!  this was the same list call that populated the drop down
      return "redirect:/index"; 
  } 
  </code></pre>
  
  <p>How can I 1) return a <code>list&lt;string&gt;</code> back from within my view model to get the list of items to reference via the selected item index to return as query param or 2) how can get the actual string literal of the selected item instead of the index?</p>
  
  <p>Thx!</p>