<p class="col-xs-2">
<select id="chapterType" name="chapterType" class="form-control" >
<c:forEach items="${chapterType}" var="cType" >
<option value="${cType.id}"
<c:if test="${chapter.chapterType==${cType.id}}">selected = selected</c:if>>
${cType.name}
</option>
</c:forEach>
</select>
</p>
迷茫2017-04-18 10:54:24
首先,el表达式里不应该再嵌套el表达式,比如${chapter.chapterType==${cType.id}}
,至少应该写成${chapter.chapterType==cType.id}
吧。
其次,我也不是太了解jsp编译的原理,比如xml的tag里再嵌tag会不会有问题。如果非要在tag里做判断,不妨用el表达式取代<c:if>
,比如:${chapter.chapterType==cType.id ? " selected=selected" : ""}