我一直在尝试使用struts2-jsf-plugin集成Struts 2和JSF 2.0,似乎没有使用facelets,我不确定这个插件是否适用于JSF 2.0规范,当我使用JSF时在JSP everthing上集成工作正常,但使用Facelets,我得到以下异常:
java.lang.IllegalStateException: Cannot determine whether or not the request is stateless
com.sun.faces.renderkit.ServerSideStateHelper.isStateless(ServerSideStateHelper.java:497)
com.sun.faces.renderkit.ResponseStateManagerImpl.isStateless(ResponseStateManagerImpl.java:168)
com.sun.faces.application.view.FaceletViewHandlingStrategy.restoreView(FaceletViewHandlingStrategy.java:549)
com.sun.faces.application.view.MultiViewHandler.restoreView(MultiViewHandler.java:150)
org.apache.struts2.jsf.RestoreViewInterceptor.executePhase(RestoreViewInterceptor.java:98)
org.apache.struts2.jsf.FacesInterceptor.intercept(FacesInterceptor.java:62)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.jsf.FacesSetupInterceptor.intercept(FacesSetupInterceptor.java:229)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.DeprecationInterceptor.intercept(DeprecationInterceptor.java:41)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ConversionErrorInterceptor.intercept(ConversionErrorInterceptor.java:138)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.MultiselectInterceptor.intercept(MultiselectInterceptor.java:73)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.CheckboxInterceptor.intercept(CheckboxInterceptor.java:91)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.PrepareInterceptor.doIntercept(PrepareInterceptor.java:171)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.interceptor.ServletConfigInterceptor.intercept(ServletConfigInterceptor.java:164)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ExceptionMappingInterceptor.intercept(ExceptionMappingInterceptor.java:189)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
com.opensymphony.xwork2.interceptor.ParametersInterceptor.doIntercept(ParametersInterceptor.java:249)
com.opensymphony.xwork2.interceptor.MethodFilterInterceptor.intercept(MethodFilterInterceptor.java:98)
com.opensymphony.xwork2.DefaultActionInvocation.invoke(DefaultActionInvocation.java:246)
org.apache.struts2.impl.StrutsActionProxy.execute(StrutsActionProxy.java:54)
org.apache.struts2.dispatcher.Dispatcher.serviceAction(Dispatcher.java:562)
org.apache.struts2.dispatcher.ng.ExecuteOperations.executeAction(ExecuteOperations.java:77)
org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter.doFilter(StrutsPrepareAndExecuteFilter.java:99)
org.displaytag.filter.ResponseOverrideFilter.doFilter(ResponseOverrideFilter.java:125)
com.aritec.bank.filters.EmpresaSeleccionadaFilter.doFilter(EmpresaSeleccionadaFilter.java:101)
org.jboss.web.tomcat.filters.ReplyHeaderFilter.doFilter(ReplyHeaderFilter.java:96)
我使用struts2-core-2.3.16和struts2-jsf-plugin-2.3.16和jsf 2.2.6。
有没有人遇到过这个问题?我也使用旧版本的JBoss AS,它是4.2.0,我想知道是否可能导致这个问题。我正在使用JDK 7.我在web.xml上配置了Facelets Servlet:
<servlet>
<servlet-name>faces</servlet-name>
<servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet>
<servlet-name>JspSupportServlet</servlet-name>
<servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>faces</servlet-name>
<url-pattern>*.action</url-pattern>
</servlet-mapping>
我还在struts.xml中配置了我的操作,如下所示:
<package name="jsf" extends="jsf-default" namespace="/jsf">
<result-types>
<result-type name="jsf" class="org.apache.struts2.jsf.FacesResult"/>
</result-types>
<interceptors>
<interceptor-stack name="jsfFullStack">
<interceptor-ref name="params" />
<interceptor-ref name="basicStack"/>
<interceptor-ref name="jsfStack"/>
</interceptor-stack>
</interceptors>
<default-interceptor-ref name="jsfFullStack"/>
<action name="test" class="com.jsf.actions.JSFTestAction" method="test">
<result name="success" type="jsf"/>
</action>
</package>
由于JSF 2.0不需要视图处理程序,因此我有一个空的faces-config.xml。