• 在struts的ActionForward中添加参数

    2004-12-13

    Tag:学习

    版权声明:转载时请以超链接形式标明文章原始出处和作者信息及本声明
    http://shidu.blogbus.com/logs/540365.html

    配置文件大概如下:
    <action-mappings>
        <action path="/account"
             name="accountForm"
             parameter="action"
             scope="request"
             type="com.ai.uaap.admin.web.action.AccountAction">
          <forward name="listOK" path="/AccountMaster.jsp" />
          <forward name="removeOK" path="/account.do?action=list" redirect="true" />
    </action>

        我在执行完remove的方法之后的代码是return mapping.findForward("removeOK")。这时就会访问account.do?action=list这个地址,以前我想在account.do?action=list之后继续添加参数(例如account.do?action=list&abc=123)不知道该怎么实现。

        今天看到一个资料给出了实现:
    String path = mapping.findForward("removeOK").getPath();
    ActionForward forward = new ActionForward(path + "&abc=123", true);
    //这里的true是Redirect
    return forward;

        ok,搞定^_^。以前干嘛吃的,怎么这么简单都没想到。


    收藏到:Del.icio.us