[b]这个很有意思,可以利用struts的配置文件<action>的<forward>来定向,可以完全不用,也可以2者结合。[/b]
ret = new ActionForward(mapping.findForward("list").getPath() + "?cnid="+request.getParameter("cnid")+"&type="+ request.getParameter("type")) ;
象上面那么写就可以了,
其实感觉完全的被欺骗,没看过源代码,
刚看了一下,其实ActionForward的原理非常简单,就是设置路径么,
所以, 完全可以按照上面 的方式, 组合自己的url作为forward!
木有意思
new ActionForward("xx.do?"+"param1="+param1+"¶m2="+param1)
构建ActionForward对象
ActionForward类提供了下面五种构造器:
public ActionForward()
public ActionForward(String path)
public ActionForward(String path, boolean redirect)
public ActionForward(String name, String path, boolean redirect)
public ActionForward(String name, String path, boolean redirect, boolean contextRelative)
虽然这些构造器是不需要说明的,但我们应该注意下面几点。在这些构造器中,第二种可能是最常用的。后四种构造器中的path参数表示的是到目的资源的路径。后三种构造器中的redirect布尔值表示的是是否执行了一个重定向(redirect)。(缺省情况下,这个值设置为false,因为redirect比forward慢。)最后,第五个构造器中的contextRelative布尔值表示该路径是否应该是context-relative的,而不是module-relative的。
同样,一个ActionForward实例也可以有一个逻辑名称,你可以用这个名称来查找与一个特殊的ActionMapping对象相关的实例。(参见本系列第四部分关于ActionMapping的讲述。)
学习ActionForward类的方法
ActionForward类定义了三个保护字段——name、path和redirect——它们构成了ActionForward的三个属性。ActionForward类提供getter和setter方法来从这些字段读值、给这些字段赋值。这些方法是不需要说明的,定义如下:
public boolean getContextRelative()
public void setContextRelative(boolean contextRelative)
public String getName()
public void setName(String name)
public String getPath()
public void setPath(String path)
public boolean getRedirect()
public void setRedirect(boolean redirect)
除此之外,ActionForward类还重载了toString方法并返回:"ActionForward[" + name + "]"其中name是名称字段。
最后,还有一个freeze方法,它固定了一个组件的配置。
ret = new ActionForward(mapping.findForward("list").getPath() + "?cnid="+request.getParameter("cnid")+"&type="+ request.getParameter("type")) ;
象上面那么写就可以了,
其实感觉完全的被欺骗,没看过源代码,
刚看了一下,其实ActionForward的原理非常简单,就是设置路径么,
所以, 完全可以按照上面 的方式, 组合自己的url作为forward!
木有意思
new ActionForward("xx.do?"+"param1="+param1+"¶m2="+param1)
构建ActionForward对象
ActionForward类提供了下面五种构造器:
public ActionForward()
public ActionForward(String path)
public ActionForward(String path, boolean redirect)
public ActionForward(String name, String path, boolean redirect)
public ActionForward(String name, String path, boolean redirect, boolean contextRelative)
虽然这些构造器是不需要说明的,但我们应该注意下面几点。在这些构造器中,第二种可能是最常用的。后四种构造器中的path参数表示的是到目的资源的路径。后三种构造器中的redirect布尔值表示的是是否执行了一个重定向(redirect)。(缺省情况下,这个值设置为false,因为redirect比forward慢。)最后,第五个构造器中的contextRelative布尔值表示该路径是否应该是context-relative的,而不是module-relative的。
同样,一个ActionForward实例也可以有一个逻辑名称,你可以用这个名称来查找与一个特殊的ActionMapping对象相关的实例。(参见本系列第四部分关于ActionMapping的讲述。)
学习ActionForward类的方法
ActionForward类定义了三个保护字段——name、path和redirect——它们构成了ActionForward的三个属性。ActionForward类提供getter和setter方法来从这些字段读值、给这些字段赋值。这些方法是不需要说明的,定义如下:
public boolean getContextRelative()
public void setContextRelative(boolean contextRelative)
public String getName()
public void setName(String name)
public String getPath()
public void setPath(String path)
public boolean getRedirect()
public void setRedirect(boolean redirect)
除此之外,ActionForward类还重载了toString方法并返回:"ActionForward[" + name + "]"其中name是名称字段。
最后,还有一个freeze方法,它固定了一个组件的配置。