出现错误:
java.lang.IllegalStateException:
No WebApplicationContext found: no ContextLoaderListener registeredatorg.springframework.web.filter.DelegatingFilterProxy.doFilter(DelegatingFilterProxy.java:252)at org.apache.catalina.core.ApplicationFilterChain.internalDoFilter(ApplicationFilterChain.java:241)
我的web.xml
配置声明为DelegatingFilterProxy
。如果有不同的身份验证规则,我如何在我的过滤器中写入?通过那些差异名称?
public class SecurityFilter implements Filter{
@Autowired
private TokenService tokenService;
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
String token = request.getParameter("token");//:TODO}}
和spring config是:
<bean id="securityFilter" class="xx.filter.SecurityFilter"></bean>
答案 0 :(得分:0)
filter类不是spring anootated类,因此不会加载任何依赖spring相关的类。理想情况下,如果您将UserFilter注释为弹簧组件,那么您的@autowired dependents也将加载。