我正在使用Spring MVC并将县列表设置为请求。 我将列表设置为页面请求,但“选定”选项在HTML页面上未突出显示。选择下拉“选定”选项不会突出显示
我的控制器代码如下:
//Populate drop down selection with list of counties ArrayList<County> counties = countyInformation.getCounties(State, Zip); request.setAttribute("counties", counties);
我的JSP代码如下:
<form:select class="form-control" path="counties">
<form:option value="Select County"></form:option>
<form:options items="${countiesList}" itemValue="countyFipsId" itemLabel="countyName" />
</form:select>
我也试过这样:
<select id="county" name="county">
<option value="">Select County</option>
<c:forEach items="${counties}" var="county">
<c:choose>
<c:when test="${county == selectedCountyId}">
<option value="${county.countyId}" selected="selected">${county.countyName}</option>
</c:when>
<c:otherwise>
<option value="${county.countyId}" >${county.countyName}</option>
</c:otherwise>
</c:choose>
</c:forEach>
</select>
是否有任何Spring/Browser渲染中的错误? 当前,所选选项显示在开发工具栏中,但选项本身未突出显示。 It doesn't come into focus on the page
有没有一个jQuery/JavaScript等效的解决方案呢? 任何帮助非常感谢。谢谢
是的,我注意到了错误。写下来时我的错误。但是这个解决方案不起作用。我也尝试过使用,没有运气。 –
Guru
如果你可以点击我的问题中提到的图片,你会明白。基本上我希望所选项目在页面加载时突出显示。下拉选项中的选定项目未在HTML页面中突出显示。而且我无法从控制器端控制它。有没有onPageLoad JS等效解决方案? – Guru
您是否为所选项目设置了会话属性? – QuestionMarks