I am currently working on a Spring project and I faced an issue with countries list. The following list is a list of countries, I need to have a country with name emptySpace and id 0. the list is displaying countries successfully but this one country with empty space value is displayed by its id instead of its value, and开发者_Python百科 if I full the empty space with any value, like "good job" it will show good job in the country list.
<c:forEach var="country" items="${country}">
<c:choose>
<c:when test="${country.entityId == companyDetails.countryId}">
<form:option value="${country.entityId}" selected="selected">${country.name}</form:option>
</c:when>
<c:otherwise>
<form:option value="${country.entityId}">${country.name}</form:option>
</c:otherwise>
</c:choose>
</c:forEach>
any suggestions?
You can try to use label
attribute instead of tag body for passing label value:
<form:option value="${country.entityId}" label = "${country.name}" />
Since you are not using any feature of the spring form:option tag, try using the html <option> tag instead. I will not do any automatic substitutions.
精彩评论