Struts源码分析4:ActionForward

by sundy 8/7/2009 11:57:40 AM

前言:发现很多j2ee的程序员基础都差得不行 ,会用ssh的甚至都不知道为何要这样,以及如何设计的 。因此为大家简单的剖析一下Struts的设计 ,以资借鉴 。

ActionForward继承了下ForwardConfig,然后就写了6个构造函数……然后就没了 汗=。=!
有一句话没翻译出来,有看得懂的来帮个忙吧 :
NOTE - This class would have been deprecated and
replaced by org.apache.struts.config.ForwardConfig except for the fact that
it is part of the public API that existing applications are using.
下面是翻译后的源码。

package org.apache.struts.action;
import org.apache.struts.config.ForwardConfig;
/**
* 一个ActionForward为控制器类RequestProcessor指向了一个目的地,由控制器执行跳转。
* 但也可能作为Action中的行为,直接执行RequestDispatcher.forward或
* HttpServletResponse.sendRedirect方法。这个类的实例可以会根据需要被动态创建,
* 也可以被设定为与一个ActionMapping绑定,通过名字查找这个mapping实例的多个跳转目的地。

* 一个ActionForward包含以下几个基本属性,其他的附加属性可以根据需要由子类提供。

* contextRelative(上下文关系): path路径值必须被解释为上下文相关路径(context-relative)

* name : 用来查找相关的ActionMapping。
* <li><strong>name</strong> - Logical name by which this instance may be
* looked up in relationship to a particular ActionMapping. </li>
*
* path : 一个让控制器实现转发(forward)的,模型相关/上下文相关URI;或一个让控制器
* 实现重定向(redirected)的,绝对/相对URI。
*
* redirect : 当需要控制器以重定向的方法执行path时则设为true,否则为false
*
* 这个类继承了 ForwardConfig 类和 contextRelative属性
*
* 注意 :这个类不推荐使用,而应由ForwardConfig取代 ..后面的翻不出来了。
* NOTE - This class would have been deprecated and
* replaced by org.apache.struts.config.ForwardConfig except for the fact that
* it is part of the public API that existing applications are using.</p>
*          
*/
public class ActionForward extends ForwardConfig {
/**
     * 无参构造函数 - 以默认值实例化
*/
public ActionForward() {
this(null, false);
    }
/**
     * 构造函数 - 参数path</p>
     *
*/
public ActionForward(String path) {
this(path, false);
    }
/**
     * 构造函数 - 参数 path,redirect
*/
public ActionForward(String path, boolean redirect) {
super();
        setName(null);
        setPath(path);
        setRedirect(redirect);
    }
/**
     *构造函数 - 参数 name,path,redirect
*/
public ActionForward(String name, String path, boolean redirect) {
super();
        setName(name);
        setPath(path);
        setRedirect(redirect);
    }
/**
     * 构造函数 - 参数 name,path,redirect,module 模块前缀
*/
public ActionForward(String name, String path, boolean redirect,
        String module) {
super();
        setName(name);
        setPath(path);
        setRedirect(redirect);
        setModule(module);
    }
/**
     * 构造函数 - 用已有的ActionForward对象实例化。
*/
public ActionForward(ActionForward copyMe) {
this(copyMe.getName(), copyMe.getPath(), copyMe.getRedirect(),
            copyMe.getModule());
    }
}

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5

Tags:

Java & OpenSource Domain

Related posts

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.
© Copyright 2007 - 2008 Design by Sundy Linghua-Zhang 蜀ICP备08108648号

About the author

Name of author Author name
Something about me and what I do.

E-mail me Send mail

Calendar

<<  February 2012  >>
MoTuWeThFrSaSu
303112345
6789101112
13141516171819
20212223242526
2728291234
567891011

View posts in large calendar

Recent comments

Authors

Disclaimer

The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

© Copyright 2012

Sign in