首页 > 其他分享 >使用过滤器预加载数据

使用过滤器预加载数据

时间:2022-12-09 17:31:17浏览次数:48  
标签:数据 void System Override 过滤器 import servletRequest public 加载

核心用法


使用过滤器预加载数据_java


引入其它页面



<jsp:include page="head.jsp"></jsp:include>




过滤器处理数据


package filter;

import javax.servlet.*;
import javax.servlet.annotation.WebFilter;
import java.io.IOException;


@WebFilter(value = "/head.jsp", dispatcherTypes = DispatcherType.INCLUDE)
public class AFilter implements Filter {
@Override
public void init(FilterConfig filterConfig) throws ServletException {

}

@Override
public void doFilter(ServletRequest servletRequest, ServletResponse servletResponse, FilterChain filterChain) throws IOException, ServletException {
System.out.println("in2");
servletRequest.setAttribute("db", "jsp-include");
filterChain.doFilter(servletRequest, servletResponse);
System.out.println("out2");
}

@Override
public void destroy() {

}
}

标签:数据,void,System,Override,过滤器,import,servletRequest,public,加载
From: https://blog.51cto.com/u_13137233/5926319

相关文章