【发布时间】:2014-11-25 21:51:31
【问题描述】:
嗨朋友们,我在 Spring Web Flow 中工作,在每个事件之前我想要检查会话是否存在,为此我想要调用拦截器,所以我在此处配置 Web 流中的拦截器时遇到问题,ID 我的 Web 流。
<?xml version="1.0" encoding="UTF-8"?>
<beans xmlns="http://www.springframework.org/schema/beans"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:faces="http://www.springframework.org/schema/faces"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:mvc="http://www.springframework.org/schema/mvc"
xsi:schemaLocation="
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/faces http://www.springframework.org/schema/faces/spring-faces.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd
http://www.springframework.org/schema/mvc http://www.springframework.org/schema/mvc/spring-mvc.xsd">
<faces:resources />
<context:annotation-config />
<context:component-scan base-package="com.pcx.interceptor.check" />
<context:component-scan base-package="com.pcx.ui.converter" />
<mvc:interceptors>
<bean class="com.pcx.ui.converter.ExecuteTimeInterceptor" />
</mvc:interceptors>
<bean class="org.springframework.webflow.mvc.servlet.FlowHandlerMapping">
<property name="order" value="1" />
<property name="flowRegistry" ref="flowRegistry" />
<property name="defaultHandler">
<bean class="org.springframework.web.servlet.mvc.UrlFilenameViewController" />
</property>
</bean>
<!-- Maps logical view names to Facelet templates in /WEB-INF (e.g. 'search'
to '/WEB-INF/search.xhtml' -->
<bean id="faceletsViewResolver"
class="org.springframework.web.servlet.view.UrlBasedViewResolver">
<property name="viewClass" value="org.springframework.faces.mvc.JsfView" />
<property name="prefix" value="/WEB-INF/" />
<property name="suffix" value=".xhtml" />
</bean>
<!-- Dispatches requests mapped to org.springframework.web.servlet.mvc.Controller
implementations -->
<bean id="sssssssss"
class="org.springframework.web.servlet.mvc.SimpleControllerHandlerAdapter" />
<!-- Dispatches requests mapped to flows to FlowHandler implementations -->
<bean class="org.springframework.faces.webflow.JsfFlowHandlerAdapter">
<property name="flowExecutor" ref="flowExecutor" />
</bean>
</beans>
【问题讨论】:
-
问题是什么?虽然我可以猜到你的拦截器没有被解雇。您需要通过设置
interceptors属性在FlowHandlerMapping中设置它。<mvc:interceptors />将与<mvc:annotation-driven />一起使用。 -
嗨@M.Deinum 你能解释一下sir.how 吗?
-
@M.Deinum 我已经配置了 AOP,但是我如何调用拦截器先生
-
设置
interceptors属性有什么不明白的地方? Spring 的HandlerInterceptors 也与 AOP 无关,所以不确定它来自哪里。简而言之,删除<mvc:interceptors />并将<property name="interceptors"><bean class="com.pcx.ui.converter.ExecuteTimeInterceptor"/></property>添加到FlowHandlerMappingbean。
标签: java spring interceptor spring-webflow-2