filter中獲取spring對象

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);
}

[color=red]哥們,如果你用的是註解,那就看applicationContext.xml這個中use-default-filters你就懂了![/color]
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章