FilterDispatcher处理流程

org.apache.struts2.dispatcher.ng.filter.StrutsPrepareAndExecuteFilter

前身是:org.apache.struts2.dispatcher.FilterDispatcher

请求被web.xml中定义的过滤器拦截。

3层过滤器处理:ActionContextCleanUp,其他过滤器(Other Filters, SiteMesh),FilterDispatcher

——FilterDispatcher中首先询问ActionMapper是否需要调用某个Action

——如果调用,把请求交给ActionProxy

——ActionProxy通过struts.xml找到Action类。

——ActionProxy创建一个ActionInvocation实例。并调用Action。调用之前ActionInvocation会加载Action的所有拦截器。

执行完ActionInvocation负责根据struts.xml中的配置找到相应的返回结果result

==========================================================================

Servlet中过滤器概念】【StrutsPrepareAndExecuteFilter 

过滤器API包括3个简单的接口:FilterFilterChainFilterConfig

Filter接口:

——init():容器实例化过滤器的时候调用。容器为这个方法传入FilterConfig,配置信息。

——doFilter():处理请求和响应请求。接受3个参数:ServletRequest,ServletResponse,FilterChain

        调用FilterChaindoFilter()方法。

设置ValueStack。获取ActionMapping

——destroy()方法。

 

原文地址:https://www.cnblogs.com/lsx1993/p/4841520.html