在 web 中配置过滤器
<!-- 过滤器 -->
<filter>
<filter-name>a</filter-name>
<filter-class>com.filter.fileter</filter-class>
</filter>
<filter-mapping>
<filter-name>a</filter-name>
<url-pattern>/a.*</url-pattern>
</filter-mapping>
写一个过滤器处理类
public class fileter implements Filter {
public void destroy() {
// TODO Auto-generated method stub
}
public void doFilter(ServletRequest request, ServletResponse response,
FilterChain chain) throws IOException, ServletException {
// 此处为即将要进行处理的代码
request.getRequestDispatcher("error.jsp").forward(request, response);
}
public void init(FilterConfig filterConfig) throws ServletException {
// TODO Auto-generated method stub
}
本文介绍如何在Web应用中配置过滤器,并提供了一个简单的过滤器处理类实现示例。该示例展示了过滤器的基本结构,包括初始化、销毁方法及核心处理流程。
42万+

被折叠的 条评论
为什么被折叠?



