web.xml
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/classes/spring/*.xml
</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
applicationContext.xml
<context:component-scan base-package="com"
use-default-filters="true">
<context:exclude-filter type="annotation"
expression="org.springframework.stereotype.Controller" />
</context:component-scan>
filter
public void init(FilterConfig fConfig) throws ServletException {
Log.info("init filter!");
this.applicationContext = WebApplicationContextUtils
.getRequiredWebApplicationContext(fConfig.getServletContext());
this.signatureVerifyService = this.applicationContext.getBean(
"signatureVerifyServiceImpl", SignatureVerifyService.class);
}
哥们,如果你用的是注解,那就看applicationContext.xml这个中use-default-filters你就懂了!
filter中获取spring对象
猜你喜欢
转载自jauking.iteye.com/blog/2185599
今日推荐
周排行