views:

281

answers:

1

Hi there,

The Spring 3 MVC docs state that option tags can be rendered like this:

<tr>
      <td>Country:</td>
      <td>
          <form:select path="country">
              <form:options items="${countryList}" itemValue="code" itemLabel="name"/>
          </form:select>
      </td>
</tr>

I am using FreeMarker with Spring MVC, so I interpret this as:

<tr>
    <td>Place:</td>
    <td>
        <@form.select path="place">
            <@form.options items="${places}" itemValue="id" itemLabel="name"/>

        </@form.select>
    </td>
</tr>

When I hit the page I get the following exception:

freemarker.core.NonStringException: Error on line 40, column 73 in event.ftl
Expecting a string, date or number here, Expression places is instead a freemarker.template.SimpleSequence

What should I use instead of ${places} in my FreeMarker template so that the above works?

Thanks.

A: 

You could try the following (not tested personally)

<@form.select path="place">
    <#list Request.places as place>
       <@form.option value="${place}" label="name" />
    </#list>
</@form.select>

Hope this helps!

MagiTec