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; }