Compare Enum EL Jboss [duplicate]

2019-08-04 10:20发布

This question already has an answer here:

I'm trying compare two enum values in JSTL. In my Tomcat works fine, but when I deploy the application in a Jboss doesn't work.

Enum class:

public enum Status {

    VALID,
    NOT_VALID,
    OTHER,
    ;

    public String getName() {
        return name();
    }
}

Piece of JSP:

...
<%@ page import="my.package.Status" %>
...

<c:choose>
    <c:when test="${myVar.status.toString() == Status.VALIDAD.toString()}">
        <c:set var="clase" value="green-text" />
    </c:when>
    <c:when test="${myVar.status.toString() == Status.NOT_VALIDADO.toString()}">
        <c:set var="clase" value="yellow-text" />
    </c:when>
    <c:otherwise>
        <c:set var="clase" value="red-text" />
    </c:otherwise>
</c:choose>
<span class="${clase}">

    <%-- Output tests --%>
    [${myVar.status}] - <%-- Works in Tomcat and Jboss --%>
    [${Status.VALIDAD.toString()}] - <%-- Works in Tomcat, empty in Jboss --%>
    [${Status.VALIDAD}] - <%-- Works in Tomcat, empty in Jboss --%>
    [${Status.VALIDAD.name}] - <%-- Works in Tomcat, empty in Jboss --%>
    [${Status.VALIDAD.name()}]  <%-- Works in Tomcat, empty in Jboss --%>

</span>

I have readed this and this, but I don't understand because works in Tomcat and not in Jboss.

Some idea?

EDIT:

I have tried with Jboss EAP 7.0.0 that includes the library jboss-el-api_3.0_spec-1.0.6.Final-redhat-1.jar, but still doesn't work. Also I have tested with Java 1.7 and Java 1.8.

1条回答
别忘想泡老子
2楼-- · 2019-08-04 10:47

Most likely your JBoss uses another JSP/Servlet API version than your Tomcat.

From another question related to this one:

JSP/Servet 2.4 doesn't support method calls in EL and only support properties.

查看更多
登录 后发表回答