对应的时序图
public ActionForward execute(
ActionMapping mapping,
ActionForm form,
HttpServletRequest request,
HttpServletResponse response)
throws Exception {
// Was this transaction cancelled?
if (isCancelled(request)) {
if (log.isInfoEnabled()) {
log.info(
" "
+ mapping.getAttribute()
+ " - Registration transaction was cancelled");
}
removeFormBean(mapping, request);
return (mapping.findForward("success"));
}
return mapping.findForward("success");
}
上面为何不直接在Action的方法中直接返回视图页面。而是把success对应的index.jsp放到配置文件中
实现的是解耦。在源代码中不能看到跳转的页面具体是什么了。
对应着struts-config中的
<!-- Registration Actions -->
<action path="/registration" forward="/registration.jsp" />
<action path="/registration-submit"
type="org.apache.struts.webapp.validator.RegistrationAction"
name="registrationForm"
scope="request"
validate="true"
cancellable="true"
input="input">
<forward name="input" path="/registration.do" />
<forward name="success" path="/index.jsp" />
</action>
扩展: http://liuxi1024.iteye.com/blog/1113398