java class:
public class UserAction extends Action {
      public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
      throws Exception
{
   switch 
   case 1: return actionMapping.findForward("f1");
   case 2: return actionMapping.findForward("f2");
}
}
struts-config:
<action path="/aaa" type="UserAction" name="aaaForm" validate="false">
    <forward name="f1" path="/f1.jsp?arg1=aaa"/>
    <forward name="f2" path="/f2.jsp?arg1=aaa"/>
</action>

解决方案 »

  1.   


    public class UserAction extends Action {
          public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
          throws Exception {
       ......
       ......
       我现在想根据我的业务的返回值返回不同的URL,而且URL里面还包含参数,格式可能为"XXX/ABC.htm?name=" + name;
       然后将上面的这个动态拼出来URL来返回。而不仅仅根据结果返回 secuess 或者 error 什么的。
       可能我还没说明白,我是根据我的业务来返回不同URL的,我会在这个程序里对数据库进行查询。
       String url = "XXX/ABC.htm?name=" + name;//name 是我从数据库中动态查询出来的
      //而上面哥们告诉我的方法是把url写死在配置文件里面的,这样我的所有name值就只能固定了,不能动态了。

       return actionMapping.findForward("success");
        }
    }
      

  2.   

     String url = "XXX/ABC.htm?name=" + name
    变化的只有name吧??你跳转的网页就一个....干嘛要这样传参数name啊?
      

  3.   

    把name属性放在request里面不就行了?public class UserAction extends Action {
          public ActionForward execute(ActionMapping actionMapping, ActionForm actionForm, HttpServletRequest httpServletRequest, HttpServletResponse httpServletResponse)
          throws Exception {
       ......
       ......
       String url = "XXX/ABC.htm" 
       httpServletRequest.setAttribute("name", name);
       return actionMapping.findForward("success");
        }
    }
      

  4.   

    我的需求是这样的,在我的execute()方法里面对数据库进行相关的查询后想拼出来一个动态的url,我的目标页呢并不是.jsp页面,所以不能用.jsp的内建对象来取值。所以我就只能用url来传值。
      

  5.   

    httpServletRequest.sendRedirect("");
    or write forward method and invoke itgive 分