拦截器@Service注入失效解决方式
if (redisUtils == null) {//解决service为null无法注入问题
System.out.println("redisUtils is null!!!");
BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext());
redisUtils = (RedisUtils) factory.getBean("redisUtils");
}
原因:拦截器加载的时间点在springcontext之前,所以在拦截器中注入自然为null