JSTL和select标签的组合使用
时间:2014-05-09 08:47:09
收藏:0
阅读:362
1.用于根据不同的值显示对应的内容,不能选择
<select name="grade"> <c:choose> <c:when test="${grade == ‘A‘}"> <option value="A" selected>A</option> </c:when> <c:when test="${grade == ‘B‘}"> <option value="B" selected>B</option> </c:when> <c:when test="${grade == ‘C‘}"> <option value="C" selected>C</option> </c:when> </c:choose> </select>
2.用于根据值设置select的默认选项,可以选择
<select name="grade"> <option value="A" <c:if test="${grade==‘A‘}">selected</c:if>>A</option> <option value="B" <c:if test="${grade==‘B‘}">selected</c:if>>B</option> <option value="C" <c:if test="${grade==‘C‘}">selected</c:if>>C</option> </select>
评论(0)