开发者

Issue with empty space value in countries list

开发者 https://www.devze.com 2023-02-05 01:04 出处:网络
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 disp

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.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号