zoukankan      html  css  js  c++  java
  • filter中获取spring bean

    import java.io.IOException;
    
    import javax.servlet.Filter;
    import javax.servlet.FilterChain;
    import javax.servlet.FilterConfig;
    import javax.servlet.ServletException;
    import javax.servlet.ServletRequest;
    import javax.servlet.ServletResponse;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    
    import org.apache.commons.lang.StringUtils;
    import org.slf4j.Logger;
    import org.slf4j.LoggerFactory;
    import org.springframework.web.context.WebApplicationContext;
    
    import com.alibaba.fastjson.JSON;
    import com.viewalloc.base.common.model.contants.ResultCodeType;
    import com.viewalloc.base.common.model.dto.InvokeResult;
    import com.viewalloc.base.common.redis.VARedisTemplate;
    import com.viewalloc.scan.admin.common.utils.CookieUtils;
    
    public class LoginFilter  implements Filter {
    
        private WebApplicationContext wac;
        
        private Logger log = LoggerFactory.getLogger(this.getClass());
        
        @Override
        public void destroy() {
            
        }
    
        private static final String[] NO_FILTER_URL = new String[]{"/api/user/session","/api/user/logout","login.html","/api/version"};
        
        @Override
        public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain)
                throws IOException, ServletException {
            VARedisTemplate redis = wac.getBean(VARedisTemplate.class);
        }
    
        @Override
        public void init(FilterConfig arg0) throws ServletException {
            wac = (WebApplicationContext) arg0.getServletContext().getAttribute(WebApplicationContext.ROOT_WEB_APPLICATION_CONTEXT_ATTRIBUTE);
        }
    
    }
  • 相关阅读:
    altium designer 工程中的原理图库和封装如何提取出来
    555是集成电路
    安装JDK+Tomcat,进行环境变量设置,和运行JSP
    2018年房价会涨吗?
    MySQLroot密码的恢复方法
    mysql中的数据类型长度
    感觉还不错,受益很高,有保障
    phpstorm问题
    Mac上的抓包工具Charles
    解决Firefox显示“已阻止载入混合活动内容”的方法
  • 原文地址:https://www.cnblogs.com/chyg/p/5362777.html
Copyright © 2011-2022 走看看