struts2-流程詳解-StrutsPrepareAndExecuteFilter

http://hi.baidu.com/liangzhongbo/item/07be3a560c16bc13da163536apache

 

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

初始化:session

public void init(FilterConfig filterConfig)
throws ServletException
{
InitOperations init = new InitOperations();
FilterHostConfig config = new FilterHostConfig(filterConfig);
init.initLogging(config);
Dispatcher dispatcher = init.initDispatcher(config);
init.initStaticContentLoader(config, dispatcher);
prepare = new PrepareOperations(filterConfig.getServletContext(), dispatcher);
execute = new ExecuteOperations(filterConfig.getServletContext(), dispatcher);
excludedPatterns = init.buildExcludedPatternsList(dispatcher);
postInit(dispatcher, filterConfig);
init.cleanup();
break MISSING_BLOCK_LABEL_108;
Exception exception;
exception;
init.cleanup();
throw exception;
}app

執行任務post

public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain)ui

throws IOException, ServletException
{
HttpServletRequest request;
HttpServletResponse response;
request = (HttpServletRequest)req;
response = (HttpServletResponse)res;
prepare.setEncodingAndLocale(request, response);spa

/*爲當前線程建立ActionContext,ActionContext是ThreadLocal的,ActionContent其實就是一個線程安全的HashMap,它內部使用一個HashMap線程

來儲存相關信息,這個map的構造是使用dispatcher.createContextMap(request, response, null, servletContext)來造成的,這個3d

map包括的信息有session,request,response,ServletContext,RequestMap,SessionMap等各類信息,能夠通get

個這個ActionContent取得各類信息,例如ActionContext.getContext().getSession()來得到當前的Session,

若是要得到request或者response必須用ServletActionContext它是ActionContent的子類,提供更多的方法,如

果是forward那也會新建一個新的ActionContent,這個新的ActionContent直接使用舊的ActionContent的數據來

構造*/

prepare.createActionContext(request, response); prepare.assignDispatcherToThread(); if(excludedPatterns != null && prepare.isUrlExcluded(request, excludedPatterns)) { chain.doFilter(request, response); } else { request = prepare.wrapRequest(request); org.apache.struts2.dispatcher.mapper.ActionMapping mapping = prepare.findActionMapping(request, response, true); if(mapping == null) { boolean handled = execute.executeStaticResourceRequest(request, response); if(!handled) chain.doFilter(request, response); } else { execute.executeAction(request, response, mapping); } } prepare.cleanupRequest(request); break MISSING_BLOCK_LABEL_178; Exception exception; exception; prepare.cleanupRequest(request); throw exception; }

相關文章
相關標籤/搜索