gpt4 book ai didi

jsf - 使用 JSF 2.0 中的可变参数调用方法

转载 作者:行者123 更新时间:2023-12-01 12:55:44 29 4
gpt4 key购买 nike

在支持 bean 中,我声明了以下方法

public boolean hasPermission(Object... objects) {
...
}

我试图从 JSF 2.0 调用它,如下所示:
<c:set var="hasPermission" scope="view" value="#{restrictions.hasPermission(entity)}" />

它抛出
javax.el.ELException:  Cannot convert Entity of class com.testing.Entity to class [Ljava.lang.Object;

如果我传递两个参数,那么它会抛出
Method hasPermission not found

我可以从 JSF 2.0 以某种方式调用 varargs 方法吗?

最佳答案

EL 不正式支持 Varargs。至少,它没有在 EL specification. 中指定似乎也没有任何计划在即将到来的 EL 3.0 中引入它。 .

您需要寻找不同的解决方案。由于功能需求不明确,我不能推荐任何一个。

更新 Tomcat 中提供的 Apache EL 解析器似乎支持这一点。至少在 Glassfish 中提供的 Sun/Oracle EL 解析器不支持它。

关于jsf - 使用 JSF 2.0 中的可变参数调用方法,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9912218/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com