<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>
首先,el表達式裡不應該再嵌套el表達式,例如
${chapter.chapterType==${cType.id}}
,至少应该写成${chapter.chapterType==cType.id}
吧。其次,我也不是太了解jsp編譯的原理,例如xml的tag內再嵌tag不會有問題。如果非要在tag裡做判斷,不妨用el表達式取代
<c:if>
,比如:${chapter.chapterType==cType.id ? " selected=selected" : ""}