tlias管理系统--登录校验-过滤器Filter快速入门
This commit is contained in:
@@ -2,8 +2,11 @@ package com.inmind;
|
|||||||
|
|
||||||
import org.springframework.boot.SpringApplication;
|
import org.springframework.boot.SpringApplication;
|
||||||
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
import org.springframework.boot.autoconfigure.SpringBootApplication;
|
||||||
|
import org.springframework.boot.web.servlet.ServletComponentScan;
|
||||||
|
|
||||||
@SpringBootApplication
|
@SpringBootApplication
|
||||||
|
//开启对servlet组件的支持
|
||||||
|
@ServletComponentScan
|
||||||
public class TliasWebManagementApplication {
|
public class TliasWebManagementApplication {
|
||||||
|
|
||||||
public static void main(String[] args) {
|
public static void main(String[] args) {
|
||||||
|
|||||||
@@ -0,0 +1,27 @@
|
|||||||
|
package com.inmind.filter;
|
||||||
|
|
||||||
|
import javax.servlet.*;
|
||||||
|
import javax.servlet.annotation.WebFilter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@WebFilter(urlPatterns = "/*")
|
||||||
|
public class DemoFilter implements Filter {
|
||||||
|
@Override
|
||||||
|
public void init(FilterConfig filterConfig) throws ServletException {
|
||||||
|
Filter.super.init(filterConfig);
|
||||||
|
System.out.println("init,过滤器的初始化方法执行了");
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void doFilter(ServletRequest request, ServletResponse response, FilterChain filterChain) throws IOException, ServletException {
|
||||||
|
System.out.println("doFilter,过滤器的拦截方法执行了");
|
||||||
|
//放行
|
||||||
|
filterChain.doFilter(request,response);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void destroy() {
|
||||||
|
Filter.super.destroy();
|
||||||
|
System.out.println("destroy,过滤器的销毁方法执行了");
|
||||||
|
}
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user