关于在filter中获取WebApplicationContext的实践
网上很多说法,诸如:
<param-name>contextConfigLocation</param-name> <param-value> classpath:spring-context.xml </param-value>
WebApplicationContext wac = WebApplicationContextUtils.getWebApplicationContext(getServletContext());
之类的,尝试了之后报错:No WebApplicationContext found: no ContextLoaderListener registered?
最后的解决方法是:
1 this.initWebApplicationContext(getServletContext());
另外一个顺带提一下,classpath指向WEB-INF/classes/