本帖最后由 chunbin0220 于 2010-03-18 00:17:53 编辑

解决方案 »

  1.   

    时间紧,随便写了一个,不一定准确,多多包涵哈在web.xml中添加一个过滤器,命名为myfilter,在对应的文件中添加如下代码,将文件编译之后产生的.class文件放入该工程根目录下的WEB-INF(WEB-INF中的classes文件夹)中
    import java.io.*;
    import javax.servlet.*;
    import javax.servlet.http.*;
    public final class myfilter implements Filter {
        private FilterConfig filterConfig = null;    public void init(FilterConfig filterConfig) 
    throws ServletException {
    this.filterConfig = filterConfig;
        }    public void destroy() {
    this.filterConfig = null;
        }    public void doFilter(ServletRequest request_1,
     ServletResponse response_1, FilterChain chain) 
    throws IOException, ServletException 
    {
          HttpServletRequest request=(HttpServletRequest)request_1;  
          HttpServletResponse response=(HttpServletResponse)response_1;
          
       
             String  userurl = request.getRequestURI();  //截获URL
             int index_1 = userurl.lastIndexOf('.')+1;  
         
             String  temp = userurl.substring(index_1);  //获取URL的后缀,并判断是不是html
             if(temp.equals("html"))
             {
                作出处理的代码;
             }
             
                             
         chain.doFilter(request, response);
        }
    }