zoukankan      html  css  js  c++  java
  • springboot的filter使用

    package com.filter;
    
    import org.springframework.core.annotation.Order;
    
    import javax.servlet.*;
    import javax.servlet.annotation.WebFilter;
    import javax.servlet.http.HttpServletRequest;
    import javax.servlet.http.HttpServletResponse;
    import javax.servlet.http.HttpSession;
    import java.io.IOException;
    
    @WebFilter(urlPatterns = {"*.do", "/"})
    @Order(value = 1)
    public class LoginFilter implements Filter {
    
        @Override
        public void init(FilterConfig filterConfig) {
    
        }
    
        @Override
        public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
           
        }
    
        @Override
        public void destroy() {
    
        }
    
    }

    其中@Order表示优先级

    @WebFilter必须有,urlPatterns可以跟多个pattern

    然后再加上注解@ServletComponentScan

    package com;
    
    import org.mybatis.spring.annotation.MapperScan;
    import org.springframework.boot.SpringApplication;
    import org.springframework.boot.autoconfigure.SpringBootApplication;
    import org.springframework.boot.web.servlet.ServletComponentScan;
    import org.springframework.context.annotation.ImportResource;
    
    @SpringBootApplication
    @ServletComponentScan
    public class DemoApplication {
    
        public static void main(String[] args) {
            SpringApplication.run(DemoApplication.class, args);
        }
    
    }
  • 相关阅读:
    制作USB系统盘
    01Mysql 配置方法
    Tec_010_怎样看K线图
    回顾5年内的央行加息历史
    推荐:微软下一代操作系统Windows 7版本详解
    关于USB启动盘制作
    Delphi Program test
    圣诞节 玩具
    敏捷宣言
    [转 TDD] 如何坚持TDD:使用者出现的问题以及解决方案
  • 原文地址:https://www.cnblogs.com/chenmz1995/p/10369574.html
Copyright © 2011-2022 走看看