Html JSTL标记集/if
使用JSTL if进行评估 为什么在Html JSTL标记集/if,html,jsp,jstl,Html,Jsp,Jstl,使用JSTL if进行评估 为什么在 <c:set var="isOnline" value="${friend.online}"/> <h:outputText value="#{isOnline}" /> <br/> (isOnline) is: ${isOnline} <c:if test="${isOnline == 'true'}" var="theTruth"> <h:outputText value="hello"/>
<c:set var="isOnline" value="${friend.online}"/>
<h:outputText value="#{isOnline}" />
<br/>
(isOnline) is: ${isOnline}
<c:if test="${isOnline == 'true'}" var="theTruth">
<h:outputText value="hello"/>
</c:if>
<br/>
(isOnline == 'true') is: ${theTruth}
我不太清楚为什么条件被评估为false,即使我正在打印显示为true的isOnline值
任何帮助都将不胜感激。。提前感谢如果是布尔值,则不应将其与字符串进行比较。照办
<c:if test="${isOnline}">
有关使用
rendered
属性的更多示例,请选中。如果是布尔值,则不应将其与字符串进行比较。照办
<c:if test="${isOnline}">
有关使用
rendered
属性的更多示例,请选中。谢谢您的回答,我可能会按照您的建议使用rendered。因为我在使用JSTL if时会有奇怪的行为。即使friend.online是布尔值,但使用时仍然会被计算为false,我不知道为什么。然后您在h:dataTable
中使用此函数。改用呈现的属性。另请参阅链接答案。感谢您的回答,我可能会按照您的建议使用渲染。因为我在使用JSTL if时会有奇怪的行为。即使friend.online是布尔值,但使用时仍然会被计算为false,我不知道为什么。然后您在h:dataTable
中使用此函数。改用呈现的属性。另请参见链接的答案。
<h:outputText value="Hello" rendered="#{friend.online}" />