小编典典

从JSF页面将枚举值作为参数传递给Bean方法后,迁移到tomcat后失败

tomcat

我最近将JSF应用程序(使用primefaces)从glassfish 3.1迁移到了tomcat7服务器。以前通过actionlistener
属性work将enum值作为字符串传递给托管bean方法(不需要使用转换器将字符串转换为enum),但现在失败了
javax.el.MethodNotFoundException

JSF页面:

<h:form>
   <h:outputLabel value="Title"/><br/>
   <p:inputText value="#{lobController.current.title}"/>

   <p:commandButton action="#{lobController.create('CAR')}"

value=”Post”/>

bean豆法

public void create(Type type) {
  ...
}

日志消息:

javax.el.MethodNotFoundException:/_newLOB.xhtml @ 85,111 action
=“#{lobController.create(’CAR’)}”“:未找到方法:com
d432.xontrollers.LOBController@15b2cec.create(java.lang.String)
.sun.faces.application.ActionListenerImpl.processAction(ActionListenerImpl.java:110)在javax.faces.component.UICommand.broadcast(UICommand.java:315)在javax.faces.component.UIData.broadcast(UIData.java:1093
)的javax.faces.component.UIData.broadcast(UIData.java:1093)的javax.faces.component.UIViewRoot.broadcastEvents(UIViewRoot.java:794)的javax.faces.component.UIViewRoot.processApplication(UIViewRoot.java:
1259)位于com.sun.faces.lifecycle.InvokeApplicationPhase.execute(InvokeApplicationPhase.java:81)位于com.sun.faces.lifecycle.Phase.doPhase(Phase.java:101)位于com.sun.faces.lifecycle.LifecycleImpl
。在org.apache.catalina.java.faces.webapp.FacesServlet.service(FacesServlet.java:593)处执行(LifecycleImpl.java:118)在org.apache.catalina处的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:304)
org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243的.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
)在org.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)org的org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)的ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)org的org.primefaces.webapp.filter.FileUploadFilter.doFilter(FileUploadFilter.java:79)的org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:243)的ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)
.apache.catalina.core.ApplicationFilterChain.doFilter(ApplicationFilterChain.java:210)


编辑

如果我按以下方式更改托管bean方法,则此方法开始工作:

public void create(String type) {
     Type type = Type.valueOf(type);
     ...
}

在Tomcat 7.0.14上将Primefaces 3.1与JSF 2.1.6结合使用


阅读 211

收藏
2020-06-16

共1个答案

小编典典

这是Tomcat
EL实现中的错误。我已经为您报告了此问题问题52970。希望他们不会像我以前的报告那样挑剔。

在他们解决问题之前,最好的选择是将Glassfish 3的EL
2.2实现JAR文件
复制到您的/WEB-INF/libWeb应用程序中,并通过以下命令输入Mojarra来使用它web.xml

<context-param>     
    <param-name>com.sun.faces.expressionFactory</param-name>
    <param-value>com.sun.el.ExpressionFactoryImpl</param-value>   
</context-param>

更新 :票证提到它已修复,它将在7.0.27及更高版本中。

2020-06-16