解决方案 »

  1.   

    我的filter拦截的范围有点大,dispatch用了三个  貌似所有请求都会被过滤
      

  2.   

    用法是正确的,只是你打印的异常不对,filter中打印异常的代码换成这个试试
     try
            {
                //System.out.println("before doFliter");
                chain.doFilter(request, response);
                //System.out.println("after doFliter");              
            }
            catch(Exception e)
            {
                System.out.println("catch!");
                /*AccountException ae=(AccountException)e;
                request.setAttribute("AE",ae);*/
                System.out.println(ex.getCause().getMessage());
                request.getRequestDispatcher(errorPage).forward(request, response);
            }试试
      

  3.   

    谢谢 我弄成功了
    e.getMessage 和e.getCause.getMessage有什么不同啊?
    为什么我在servlet里面做的时候就不需要getCause呢?
      

  4.   

    没见过源码,不过我估计是这样的
    从jsp中抛出的异常不是第一时间就被Filter捕获,而是先被某个顶层方法中的try catch捕获
    然后在catch部分处理了异常比如
    catch(Exception ex){
         System.out.println("An Exception occu....")
         throw new Exception(ex);
    }
    最后才被Filter截取到