if (redisUtils == null) {//解决service为null无法注入问题
System.out.println("redisUtils is null!!!");
BeanFactory factory = WebApplicationContextUtils.getRequiredWebApplicationContext(request.getServletContext());
redisUtils = (RedisUtils) factory.getBean("redisUtils");
}
原因:拦截器加载的时间点在springcontext之前,所以在拦截器中注入自然为null
转载于:https://www.cnblogs.com/rock-turf/p/9237405.html