there is an error:
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)
and my web.xml
config is declared a DelegatingFilterProxy
. if a have different auth rule, how can i write in my filter? by those diff url name?
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}}
and spring config is:
<bean id="securityFilter" class="xx.filter.SecurityFilter"></bean>
The filter class is not an spring anootated class and hence won't load any of the dependent spring related classes. Ideally if you annotate UserFilter as a spring component then your @autowired dependents will also load.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.