Struts1.x原理图--时序图,xml配置

来源:互联网 发布:php html 表单 编辑:程序博客网 时间:2024/05/17 08:02

对应的时序图

 

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://www.cnblogs.com/brucechen50/archive/2012/06/29/2570450.html
扩展:http://liuxi1024.iteye.com/blog/1113398
原创粉丝点击