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);
        }
    
    }
  • 相关阅读:
    Boost线程库学习笔记
    sizeof运算符
    用法char ch=getchar()正确性详解
    C语言中的缓冲输出
    算术运算的溢出行为 and 一个数内存中表示1的个数
    ARP、RARP、ICMP、ping
    http和https协议
    关于宋词频率统计(R语言)
    Backbone.js API中文文档
    腾讯小Q书桌图标怎么实现的啊?
  • 原文地址:https://www.cnblogs.com/chenmz1995/p/10369574.html
Copyright © 2011-2022 走看看