我已经为这个问题苦苦挣扎了5天,但我看不到在哪里寻找解决方案。 我将JSF应用程序从2.1升级到了Mojara 2.1.17到2.2,其中包括Icefaces从3.2.0升级到了4.2.0。
我还将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>
我使用Tomcat 8.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
。
感谢您的帮助。
答案 0 :(得分:0)
我终于找到了原因。 Spring Security默认情况下启用CSRF,它将阻止我的表单上的POST
请求。禁用它可以解决问题。我输了5天!!!