Spring Web Flow 2.5.1.RELEASE 未执行 JSF2.2 流程

Spring Web Flow 2.5.1.RELEASE with JSF2.2 flow not executed

我已经为这个问题苦苦挣扎了 5 天,我不知道去哪里寻找解决方案。 我将 JSF 应用程序从 2.1 升级到 2.2,并将 Mojara 2.1.17 升级到 2.2.14,包括从 3.2.0 到 4.2.0 的 Icefaces。

我还将 Spring 3.2 升级到 5.1.2,并将 Spring Web Flow 从 2.3.2.RELEASE 升级到 2.5.1.RELEASE。问题是,迁移后所有 Spring Web Flow 都不再被调用。当我点击一个按钮时,什么也没有发生。我查看了 Web 控制台,每次单击应触发 Web 流的按钮时,我都会收到 http 403 错误。

这是我的配置片段:

<webflow:flow-executor id="flowExecutor">
    <webflow:flow-execution-listeners>
        <webflow:listener ref="facesContextListener"/>
        <webflow:listener ref="icefacesFlowListener" />
    </webflow:flow-execution-listeners>
</webflow:flow-executor>

<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
    <property name="flowRegistry" ref="flowRegistry"/>
    <property name="order" value="0"/>
</bean>

<bean id="facesContextListener" 
    class="org.springframework.faces.webflow.FlowFacesContextLifecycleListener" />

<faces:flow-builder-services id="flowBuilderServices" development="true" />

<webflow:flow-registry id="flowRegistry" flow-builder-services="flowBuilderServices" base-path="/WEB-INF/flows">
    <webflow:flow-location-pattern value="**/*-flow.xml" />
</webflow:flow-registry>

faces-config.xml简单只有:

<application>
    <el-resolver>
            org.springframework.web.jsf.el.SpringBeanFacesELResolver
    </el-resolver>
</application>

还有 web.xml

<welcome-file-list>
    <welcome-file>flow/welcome</welcome-file>
</welcome-file-list>

<servlet>
    <servlet-name>Faces Servlet</servlet-name>
    <servlet-class>javax.faces.webapp.FacesServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
    <servlet-name>Faces Servlet</servlet-name>
    <url-pattern>*.xhtml</url-pattern>
</servlet-mapping>

<filter>
    <filter-name>springSecurityFilterChain</filter-name>
    <filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
</filter>

<filter-mapping>
    <filter-name>springSecurityFilterChain</filter-name>
    <url-pattern>/*</url-pattern>
</filter-mapping>

<servlet>
    <servlet-name>flowDispatchServlet</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <init-param>
        <param-name>contextConfigLocation</param-name>
        <param-value></param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
    <multipart-config />
</servlet>

<servlet-mapping>
    <servlet-name>flowDispatchServlet</servlet-name>
    <url-pattern>/flow/*</url-pattern>
</servlet-mapping>

<servlet-mapping>
    <servlet-name>flowDispatchServlet</servlet-name>
    <url-pattern>/services/*</url-pattern>
</servlet-mapping>

<resource-env-ref>
    <resource-env-ref-name>BeanManager</resource-env-ref-name>
    <resource-env-ref-type>
        javax.enterprise.inject.spi.BeanManager
    </resource-env-ref-type>
</resource-env-ref>

主要依赖:

    <spring-integration.version>5.1.0.RELEASE</spring-integration.version>
    <spring-orm.version>5.1.2.RELEASE</spring-orm.version>
    <spring-security-cas-client.version>3.0.8.RELEASE</spring-security-cas-client.version>
    <spring-security.version>5.1.2.RELEASE</spring-security.version>
    <spring.version>5.1.2.RELEASE</spring.version>
    <spring.webflow.version>2.5.1.RELEASE</spring.webflow.version>
    <spring-ws-core.version>3.0.4.RELEASE</spring-ws-core.version>
    <javax.faces.version>2.2.14</javax.faces.version>
    <icefaces-ace.version>4.2.0</icefaces-ace.version>
    <validation-api.version>2.0.1.Final</validation-api.version>

我用的是Tomcat8.5。 以及一个简单的测试流程:

 <view-state id="start" view="welcome.xhtml">
    <transition on="test" to="testView" />
 </<view-state>
 <view-state id="testView" view="test.xhtml"/>

welcome.xhtml中的按钮:

<h:form id="testForm"> 
   ....
  <h:commandButton id="btnTest" class="button" value="Test" action="test"/>
</h:form>

welcome.xhtml 呈现得很好,但是单击按钮,我得到了 403 error

感谢您的帮助。

终于找到原因了。 Spring 安全性默认启用 CSRF,这会阻止 POST 对我的表单的请求。禁用它可以解决问题。我瘦了 5 天!!!!