java - get the Autowired service in filter class -


there 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 web.xml config declared delegatingfilterproxy. if have different auth rule, how can write in filter? 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 not spring anootated class , hence won't load of dependent spring related classes. ideally if annotate userfilter spring component @autowired dependents load.


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -