Shiro Filter引发的思考
FilterChain过滤链
假设我们有两个Filter(HelloFilter 和WorldFilter ),一个请求过来的流程是这样:
HelloFilter doFilter start......
WorldFilter doFilter start......
Hello业务方法......
WorldFilter doFilter end......
HelloFilter doFilter end......
假设HelloFilter的doFilter中有请求转发或者是重定向至world业务路径且不再执行chain.doFilter(reques, response),一个请求过来的流程是这样:
HelloFilter doFilter start......
World业务方法......
HelloFilter doFilter end......
假设HelloFilter的doFilter中有请求转发或者是重定向至world业务路径且执行chain.doFilter(reques, response),一个请求过来的流程是这样:
HelloFilter doFilter start......
World业务方法......
WorldFilter doFilter start......
WorldFilter doFilter end......
HelloFilter doFilter end......
假设HelloFilter的doFilter中有请求转发或者是重定向至world业务路径且执行chain.doFilter(reques, response),WorldFilter的doFilter中有请求转发或者是重定向至filter业务路径再执行chain.doFilter(reques, response)或者是不再执行chain.doFilter(reques, response),一个请求过来的流程是这样:
HelloFilter doFilter start......
World业务方法......
WorldFilter doFilter start......
java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed
假设HelloFilter的doFilter中有请求转发或者是重定向至world业务路径且执行chain.doFilter(reques, response),WorldFilter的doFilter执行chain.doFilter(reques, response)或者是再请求转发或者是重定向至filter业务路径,一个请求过来的流程是这样:
HelloFilter doFilter start......
World业务方法......
WorldFilter doFilter start......
Hello业务方法......
java.lang.IllegalStateException: Cannot call sendRedirect() after the response has been committed