错误设置选择的选项值jsp页面

时间:2015-12-10 10:09:35

标签: jsp

我是一个新的jsp.Now,我尝试设置为这样的选项:

<c:choose>
    <c:when test = "${listMonth ne null}">
        <c:forEach items = "${listMonth}" var = "lsMonth">
            <c:choose>
                <c:when test = "${lsMonth == month}">
                    <option value = "${lsMonth}" selected = "selected">${lsMonth}</option>
                </c:when>
                <c:otherwise>
                    <c:choose>
                        <c:when test = "${lsMonth == monthNow}">
                            <option value = "${lsMonth}" selected = "selected">${lsMonth}</option>
                        </c:when>
                        <c:otherwise>
                            <option value = "${lsMonth}">${lsMonth}</option>
                        </c:otherwise>
                   </c:choose>
                </c:otherwise>
            </c:choose>
        </c:forEach>
    </c:when>
</c:choose>

但是,$ {lsMonth == month)时未选中,仅在$ {lsMonth == monthNow}时选择。请帮助我

1 个答案:

答案 0 :(得分:0)

请尝试

JSTL空检查

<c:when test = "${not empty listMonth}">

等同于JSTL

<c:if test="${lsMonth eq month}">