EL是否支持重载方法? [英] Does EL support overloaded methods?

查看:79
本文介绍了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不支持,否.它始终是

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:

返回的数组中的元素未排序,并且没有任何特定顺序.

The elements in the array returned are not sorted and are not in any particular order.

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

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

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

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