今遇到JSTL和EL同时使用问题,记录备份
由来:
EL中使用request.getAttribute("")获取属性内容,在JSTL的test作为判断使用
错误:
<c:choose>
<c:when test="${request.getAttribute("pageNow")<span style="font-family: Arial, Helvetica, sans-serif; line-height: 21px;">==1}"></span>
<a href="storeGoodsList?pageNow=1&pageSize=5">上一页</a>
</c:when>
<c:otherwise>
<a href="storeGoodsList?pageNow=<%=<span style="font-family: Arial, Helvetica, sans-serif;">request.getAttribute("pageNow")</span><span style="font-family: Arial, Helvetica, sans-serif;">%>-1&pageSize=5">上一页</a></span>
</c:otherwise>
</c:choose>
正确:
<c:choose>
<span style="white-space:pre"> </span><c:when test="${pageNow==1}">
<span style="white-space:pre"> </span><a href="storeGoodsList?pageNow=1&pageSize=5">上一页</a>
</c:when>
<span style="white-space:pre"> </span><c:otherwise>
<span style="white-space:pre"> </span><a href="storeGoodsList?pageNow=${pageNow-1}&pageSize=5">上一页</a>
<span style="white-space:pre"> </span></c:otherwise>
</c:choose>