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);
        }
    
    }
  • 相关阅读:
    ghm一般规则
    沃尔玛强推RFID内外交困:供应商阳奉阴违
    电子商务物流解决方案
    database url
    物流中新技术应用的必要性
    美国物流管理协会更名标志全球物流进入供应链时代
    业内专家激辩物流挑战与机遇
    问的智慧
    调查报告:2003年物流信息化现状及挑战
    查找在菜单里提交的报表所在职责
  • 原文地址:https://www.cnblogs.com/chyg/p/5362777.html
Copyright © 2011-2022 走看看