// Is there a form bean associated with this mapping? String attribute = mapping.getAttribute(); if (attribute == null) { return (null); }
// Look up the form bean configuration information to use String name = mapping.getName(); FormBeanConfig config = moduleConfig.findFormBeanConfig(name); if (config == null) { log.warn("No FormBeanConfig found under '" + name + "'"); return (null); } //根据 action 配置从request或session中获得form bean 实例,如果指定scope="request" //那么每次请求都是新的Request实例,那么也就不会有form bean 实例,该方法将返回null ActionForm instance = lookupActionForm(request, attribute, mapping.getScope());
// Can we recycle the existing form bean instance (if there is one)? //可以重复使用一个已经存在的form bean 实例么 try { //instance != null 且 instance 是 type 是 DynaActionForm 或 ActionForm 时返回form bean实例 //这里应该是scope="session"的情况吧,formbean保持上次请求的状态 if (instance != null && canReuseActionForm(instance, config)) { return (instance); } } catch(ClassNotFoundException e) { log.error(servlet.getInternal().getMessage("formBean", config.getType()), e); return (null); }