JSTL和select标签的组合使用

时间:2014-05-09 08:47:09   收藏:0   阅读:362

1.用于根据不同的值显示对应的内容,不能选择

bubuko.com,布布扣
<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>        
bubuko.com,布布扣

 

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>

 

 

JSTL和select标签的组合使用,布布扣,bubuko.com

评论(0
© 2014 mamicode.com 版权所有 京ICP备13008772号-2  联系我们:gaon5@hotmail.com
迷上了代码!