public void init() throws ServletException {
initInternal(); // MessageResources, 初始化Struts框架内在的消息资源,如系统日志相关的通知、警告和错误消息
initOther(); // ConvertUtils 注册
initServlet();
initChain();
ModuleConfig moduleConfig = initModuleConfig("", config);
initModuleMessageResources(moduleConfig);
initModulePlugIns(moduleConfig);
initModuleFormBeans(moduleConfig);
initModuleForwards(moduleConfig);
initModuleExceptionConfigs(moduleConfig);
initModuleActions(moduleConfig);
moduleConfig.freeze();
}
public void process(HttpServletRequest request, HttpServletResponse response)
throws IOException, ServletException {
// 上传
request = processMultipart(request);
// action.path
String path = processPath(request, response);
processLocale(request, response);
processNoCache(request, response);
processPreprocess(request, response);
this.processCachedMessages(request, response);
//找不到,就找Unknown的action mapping
ActionMapping mapping = processMapping(request, response, path);
processRoles(request, response, mapping);
//scope里面查一下,没有就创建一个并写到scope里面去
ActionForm form = processActionForm(request, response, mapping);
//收集数据:reset()一下,把form表单的name、value(转化String[])塞到properties(HashMap),合适的convert一下,塞到formbean里面去
processPopulate(request, response, form, mapping);
//validate失败,就forward到action.input
processValidate(request, response, form, mapping);
//mapping.forward
processForward(request, response, mapping);
//mapping.include
processInclude(request, response, mapping);
//有就用,没就创建一个并保存
Action action = processActionCreate(request, response, mapping);
//执行了
ActionForward forward =
processActionPerform(request, response, action, form, mapping);
//forward.path -> uri -> forward or redirect
processForwardConfig(request, response, forward);
}