ActionMapping和ActionForward分别继承ActionConfig与ForwardConfig
struts-config.xml文件在服务器启动的时候就被加载进去,其值不能动态修改,
由于配置已经在配置文件中生效,不能在这里改变已有forward对象的属性。如果需要动态更改,应该采用动态ActionForward,如下:
在配置文件中不配置forward标签,而是在action中新建一个ActionForward,这里是可以进行属性设置的
- ActionForward forward = new AcitonForward("/xxx.jsp?xx=xx");
- forward.setRedirect(true);
- return forward;
public ActionForward execute(ActionMapping mapping, ActionForm form, HttpServletRequest request, HttpServletResponse response)throws Exception {
ActionRedirect redirect = new ActionRedirect(mapping.findForward("doRedirect"));
redirect.addParameter("param1","value1");//
redirect.addParameter("param2","2");
redirect.addParameter("param3","3.0");
/**
* 或者下一种方式
*/
redirect = new ActionRedirect();
redirect.addParameter("param1","value1");//
redirect.addParameter("param2","2");
redirect.addParameter("param3","3.0");
String url = "";
redirect.setPath(url);
return redirect;
}