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);
        }
    
    }
  • 相关阅读:
    iview正在加载和关闭加载
    vue实现input输入框只能输入中文
    vue添加遮罩
    JSONP的实现原理
    vue-resource 实现 get, post, jsonp请求
    vue实例的生命周期
    IDE更新索引
    org.apache.tomcat.util.bcel.classfile.ClassFormatException: Invalid byte tag in constant pool: 19
    springmvc过滤的静态资源不起作用
    mybatis返回集合类型为map时
  • 原文地址:https://www.cnblogs.com/chyg/p/5362777.html
Copyright © 2011-2022 走看看