Jsp jstl if else选择/when不计算变量
当满足以下条件时,我尝试打印一些html:Jsp jstl if else选择/when不计算变量,jsp,jstl,el,Jsp,Jstl,El,当满足以下条件时,我尝试打印一些html: <c:choose> <c:when test="${notification.placeId} == ${place.placeId}"> ${notification.name} </c:when> <c:otherwise> placeId: ${place.placeId} - notplaceid: ${notification.placeId} <
<c:choose>
<c:when test="${notification.placeId} == ${place.placeId}">
${notification.name}
</c:when>
<c:otherwise>
placeId: ${place.placeId} - notplaceid: ${notification.placeId}
</c:otherwise>
</c:choose>
${notification.name}
placeId:${place.placeId}-notplaceid:${notification.placeId}
这张照片是:
placeId:50-notplaceid:43-notplaceid:50-notplaceid:50-notplaceid:49placeId:50-notplaceid:51-placeId:50-notplaceid:51-notplaceid:50-notplaceid:50-notplaceid:52-placeId:50-notplaceid:53-notplaceid:50-notplaceid:50-notplaceid:0
这将从“否则”语句中打印,而从不从“当”语句中打印通知名称。从打印中可以看到,粗体输出明显满足when条件,并且应该打印通知名称
有人知道发生了什么吗?使用
<c:when test="${notification.placeId == place.placeId}">
而不是
<c:when test="${notification.placeId} == ${place.placeId}">
按照您键入它的方式,test
属性将作为字符串进行计算:将${notification.placeId}
的计算结果、==
和${placeId}
的计算结果串联起来
您希望将整个内容作为布尔表达式进行计算