Expression Language Other way to invoke method

主宰稳场 提交于 2019-12-12 02:44:18

问题


I have the following code and I'm searching for an other way to do this.

public static RequestContextData getRequestContextData() {
    FacesContext fc = FacesContext.getCurrentInstance();
    ExpressionFactory ef = fc.getApplication().getExpressionFactory();
    MethodExpression me = ef.createMethodExpression( fc.getELContext(), "#{requestContextData.getRequestContextData}", String.class, new Class[0]);
    Object o = me.invoke(fc.getELContext(), null); 
    RequestContextData request = (RequestContextData) o;
    return request;
}

I found out that it causes problems after upgrading to tomcat 8. The ELContext is already resolved and with this code afterwards it wouldn't be resolved anymore. I already tried it with a managed property but this won't work.

Addition 1: The stack looks like the following:

  • xxx.getRequestContextData()
  • some other methods
  • BeanELResolver.getValue(ELContext, Object, Object)

The ELContext is in BeanELResolver and xxx the same one. That leads to the malfunction that the xxx overwrites the resolved property with false in the BeanELResolver which then returns an PropertyNotFoundException.

来源:https://stackoverflow.com/questions/44539370/expression-language-other-way-to-invoke-method

标签
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!