title: How to make a select box on a form using Spring
body: <p>I am new to Java and the Springs framework. Here is my question as formulated by a n00b (sorry if I sound like a second grader). I am trying to get a select drop down to appear on my form with a list of selectable countries. The data is stored in a MySQL table and contains a single column with the country name. I am obviously doing something wrong. I hope it is just an error caused by a simple thing I am missing. Thanks in advance for any help.</p>
  
  <p>We are using WebFlow. I have the following in my flow XML:</p>
  
  <pre><code>&lt;on-start&gt;
    &lt;evaluate expression="flowControllerActions.retrieveMBSAddressInfo()" result="address" /&gt;
    &lt;evaluate expression="flowControllerActions.retrieveCountryInfo()" 
         result="flowScope.countryListing" /&gt;
  &lt;/on-start&gt;
  </code></pre>
  
  <p><strong>retrieveCountryInfo() looks like this:</strong></p>
  
  <pre><code>public Map&lt;String, String&gt; retrieveCountryInfo() throws IOException {
      LOGGER.debug("inside retrieveMBSAddressInfo");
      Map&lt;String, String&gt; countryInfo = (Map&lt;String, String&gt;) coaService.getCountryInfo();
      return countryInfo;
  }
  </code></pre>
  
  <p><strong>coaService.getCountryInfo() looks like this:</strong></p>
  
  <pre><code>   public Map&lt;String, String&gt; getCountryInfo() {
          ArrayList &lt;Country&gt; cList = coaDao.getSelectableCountries();
          LinkedHashMap&lt;String, String&gt; retval = new LinkedHashMap&lt;String, String&gt;();
          for ( Country c : cList){
              retval.put(c.getName(), c.getName());
              log.debug(c.getName());
          }
          return retval;
      }
  </code></pre>
  
  <p><strong>coaDao.getSelectableCountries()</strong>, which populates the list looks this way:</p>
  
  <pre><code>@SuppressWarnings("unchecked")
  @Transactional(readOnly=true, propagation=Propagation.REQUIRED)
  public ArrayList&lt;Country&gt; getSelectableCountries() {
      String myLike = "%";
  
      Session mySession = sessionFactory.getCurrentSession();
  
      ArrayList&lt;Country&gt; countries = (ArrayList&lt;Country&gt;) mySession
          .createCriteria(Country.class)
              .add(Restrictions.like("name", myLike)).list();
  
      return countries;
  }
  </code></pre>
  
  <p>And finally, <strong>the JSP page</strong> tries to render the select element like this: </p>
  
  <pre><code>&lt;td&gt;
      &lt;form:select path="country" id="country"&gt;
          &lt;form:options items="${countryListing}"/&gt;
      &lt;/form:select&gt;
  &lt;/td&gt;
  </code></pre>