您的位置:首页 > 移动开发

知识库--ApplicationFilterChain(54)

2016-12-18 23:33 281 查看
ApplicationFilterChain

The org.apache.catalina.core.ApplicationFilterChain class is the implemetation of the javax.servlet.FilterChain interface. The invoke method in the StandardWrapperValve class creates an instance of this class and calls its doFilter method. The ApplicationFilterChain class’s doFilter method calls the doFilter method of the first filter in the chain. The Filter interface’s doFilter method has the following signature:

public void doFilter(ServletRequest request,ServletResponse respponse, FilterChain chain)throws IOException,ServletException


The doFilter method of the ApplicationFilterChain class passes itself as the third argument to the filter’s doFilter method.

From its doFilter method, a filter can cause the invocation of another filter by explicitly calling the doFilter method of the FilterChain object. Here is an example of the doFilter method implementation in a filter.

public void doFilter(ServletRequest request, ServletResponse response, FilterChain chain) throws IOException, ServletException {
// do something here ...
chain.doFilter(request, response);


//如果doFilter调用的是最后一个filter,接下来将会调用 servlet的service方法。
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  chain