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);
        }
    
    }
  • 相关阅读:
    微信js sdk动态引用
    mysql
    github 常用
    使用Win32DiskImager后重置SD卡
    nuxt generate静态化后回退问题
    nuxt.config有关router配置
    vue本人常用插件汇总(常更新)
    Windows Server 2008 IIS 并发请求设置
    Python 高级编程 ——观察者模式
    MYSQL语句大全
  • 原文地址:https://www.cnblogs.com/chyg/p/5362777.html
Copyright © 2011-2022 走看看