过滤器

在 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,jsp)