jstl c:如果在false

时间:2017-12-28 18:49:49

标签: jsf jstl

编辑:我将我的问题标记为重复,因为我在这里找到了答案: JSTL c:if doesn't work inside a JSF h:dataTable

我将其标记为副本而不是删除它,因为我认为它仍然可以帮助某人。

我想我犯了一些愚蠢的错误,但<c:if>中的代码会执行,尽管test中的表达式应该评估为false。

注意:我知道在使用jstl时应该有${...}而不是#{...},但我也尝试过这种方式,似乎没有区别。

<c:if test="#{(auction.isActive==0)}">
    <h:column>
        <f:facet name="header">Auction Number</f:facet>
            #{(auction.isActive)} //PRINTS 1
    </h:column>
</c:if>

我做错了什么? 我使用的是JSF - 代码用于.xhtml页面。

我的包括:

    <html xmlns="http://www.w3.org/1999/xhtml"
xmlns:ui="http://java.sun.com/jsf/facelets"
xmlns:h="http://java.sun.com/jsf/html"
xmlns:df="http://java.sun.com/jsf/composite/dreamcar_functions"
xmlns:f="http://java.sun.com/jsf/core"
xmlns:c="http://java.sun.com/jsp/jstl/core">

很抱歉,如果这看起来很基本,但我正在用java-ee完成我的第一步。

编辑 - isActive的getter和setter:

public int getIsActive() {
    return isActive;
}
public void setIsActive(int isActive) {
    this.isActive = isActive;
}

看看我做的这个测试。我将auction.isActive == 0更改为auction.isActive以生成错误,告诉我有关auction.isActive的详细信息。这里的值似乎是0:

/add_offer.xhtml @29,39 test="#{auction.isActive}" /add_offer.xhtml @29,39 test="#{auction.isActive}": Cannot convert 0 of type class java.lang.Integer to class java.lang.Boolean

0 个答案:

没有答案
相关问题