public void doFilter(ServletRequest req, ServletResponse res, FilterChain chain) throws IOException, ServletException {
//创建actioncontext的方法
prepare.createActionContext(request, response);
}
public ActionContext createActionContext(HttpServletRequest request, HttpServletResponse response) {
//创建一个值栈对象来存放map对象
ValueStack stack = dispatcher.getContainer().getInstance(ValueStackFactory.class).createValueStack();
//putALL里面的对象放到值栈的context里面去
stack.getContext().putAll(dispatcher.createContextMap(request, response, null, servletContext));
//把值栈context复制一份到actioncontext中去
ctx = new ActionContext(stack.getContext());
}
public Map
ActionMapping mapping, ServletContext context) {
// 把内置对象封装到Map中去
Map requestMap = new RequestMap(request);
Map params = new HashMap(request.getParameterMap());
Map session = new SessionMap(request);
Map application = new ApplicationMap(context);
//把内置对象和相应的Map交给createContextMap
Map
}
//把所有的Map数据存放到extraContext
public HashMap
Map parameterMap,
Map sessionMap,
Map applicationMap,
HttpServletRequest request,
HttpServletResponse response,
ServletContext servletContext) {
HashMap
extraContext.put(ActionContext.PARAMETERS, new HashMap(parameterMap));
extraContext.put(ActionContext.SESSION, sessionMap);
extraContext.put(ActionContext.APPLICATION, applicationMap);
Locale locale;
if (defaultLocale != null) {
locale = LocalizedTextUtil.localeFromString(defaultLocale, request.getLocale());
} else {
locale = request.getLocale();
}
extraContext.put(ActionContext.LOCALE, locale);
//extraContext.put(ActionContext.DEV_MODE, Boolean.valueOf(devMode));
extraContext.put(StrutsStatics.HTTP_REQUEST, request);
extraContext.put(StrutsStatics.HTTP_RESPONSE, response);
extraContext.put(StrutsStatics.SERVLET_CONTEXT, servletContext);
// helpers to get access to request/session/application scope
extraContext.put("request", requestMap);
extraContext.put("session", sessionMap);
extraContext.put("application", applicationMap);
extraContext.put("parameters", parameterMap);
AttributeMap attrMap = new AttributeMap(extraContext);
extraContext.put("attr", attrMap);
return extraContext;
}