比较Enum EL Jboss [英] Compare Enum EL Jboss

查看:140
本文介绍了比较Enum EL Jboss的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试比较JSTL中的两个枚举值。在我的Tomcat工作正常,但是当我在Jboss中部署应用程序不起作用。



枚举类:

  public enum Status {

VALID,
NOT_VALID,
OTHER,
;

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

JSP的一部分:

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

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

<% - 输出测试 - %>
[$ {myVar.status}] - <% - 在Tomcat和Jboss中工作 - %>
[$ {Status.VALIDAD.toString()}] ​​- <% - 在Tomcat中工作,在Jboss中为空 - %>
[$ {Status.VALIDAD}] - <% - 在Tomcat中工作,在Jboss中为空 - %>
[$ {Status.VALIDAD.name}] - <% - 在Tomcat中工作,在Jboss中为空 - %>
[$ {Status.VALIDAD.name()}]<% - 在Tomcat中工作,在Jboss中为空 - %>

< / span>我已经阅读过这个这个,但我不明白,因为在Tomcat中的作品,而不是Jboss。



有些想法?


$ b $我已经尝试过Jboss EAP 7.0.0,其中包括库
$ b

-api_3.0_spec-1.0.6.Final-redhat-1.jar ,但仍然不起作用。另外我已经使用Java 1.7和Java 1.8进行了测试。

解决方案

很可能您的JBoss使用另一个JSP / Servlet API版本,而不是您的Tomcat



从另一个与此相关的问题:


JSP / Servet 2.4不支持EL中的方法调用,只支持
属性。



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.

解决方案

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.

这篇关于比较Enum EL Jboss的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆