struts中ActionForward 使用mapping.findForward如何传递get参数

<!-- 配置 -->
  <forward name="a" path="a.do" />

<!-- Action中的代码 -->
ActionForward forward=mapping.findForward("a");  
ActionForward newForward=new ActionForward(forward);
String newPath=forward.getPath()+"&id=1"
newForward.setPath(newPath);
return newForward;
 
<!-- Action中的代码(第二种) -->
return new ActionForward ("a.do?id=1");


这种办法我常用,即不用再Action中写死目标地址,又可以增加动态参数。

Strust-config给你配置的目的是为了将物理地址命名,从而做到一层抽象,如果在程序中写死,就失去了设计的意义,如果需要变更这个地址的话,就要改动很多代码。

总结来自:http://topic.csdn.net/u/20071205/11/fd20e41c-6b71-4d1b-9d56-ebe1c1583200.html

原文地址:https://www.cnblogs.com/wangpei/p/2352181.html