本文介绍了EL是否支持重载方法?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我将Java EE Web应用程序升级为使用较新的PrimeFaces版本,并且突然在PrimeFaces命令链接的action属性中调用重载bean方法不再起作用.我尝试使用JSF默认命令链接对其进行测试,但该命令也不起作用.

I upgraded my Java EE web application to use newer PrimeFaces version and suddenly the call of an overloaded bean method in an action attribute of PrimeFaces commandlink did not work anymore. I tried to use JSF default commandlink to test it and this one did not work either.

方法签名如下:

public void updateA(B b);
public void updateA(A a);

它总是试图将A强制转换为B.

It always tried to cast A to B.

更好奇,升级之前如何运作?

More curious, how could it work before the upgrade?

推荐答案

EL不支持,否.它始终是 Class#getMethods() 数组,其名称(和参数数量)与EL方法调用匹配.是否每次都返回相同的方法取决于所使用的JVM make/version.也许您同时也进行了Java SE升级. Javadoc甚至这样说:

EL does not support it, no. It'll always be the first method of the Class#getMethods() array whose name (and amount of arguments) matches the EL method call. Whether it returns the same method everytime or not depends on the JVM make/version used. Perhaps you made a Java SE upgrade in the meanwhile as well. The javadoc even says this:

您不应依赖未指定的行为.给他们起一个不同的名字.

You should not rely on unspecified behaviour. Give them a different name.

这篇关于EL是否支持重载方法?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

06-27 02:34