JAVA三大组件 Servlet Filter Listener
一、快速入门
package com.itheima.servlet;
import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;
@WebFilter("/*")
public class FilterDemo implements Filter {
@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
//1.放行前对request数据进行处理
System.out.println("FilterDemo ...");
//放行
filterChain.doFilter(servletRequest,servletResponse);
//2.放行后对responce数据进行处理
System.out.println("FillerDemo2");
}
@Override
public void init(FilterConfig filterConfig) throws ServletException {
}
@Override
public void destroy() {
}
}
二、拦截路径
三、Listener了解一下不常用了