【问题标题】:How to access path attribute of action tag (struts-config.xml) in Action or dispatch action class?如何在 Action 或 dispatch action 类中访问 action 标签(struts-config.xml)的路径属性?
【发布时间】:2014-06-18 07:07:51
【问题描述】:

我使用的是DispatchAction的未指定方法,有一种情况需要知道struts-config.xml中action标签的path属性的内容,因为这个Action类被用于两个动作路径。

例如:

<action **path="/auditor/adminOtherInfo"** **type="org.sae.aab.struts.action.OtherInfoAction"**
            scope="request" name="AdminOtherInfoForm" parameter="method" validate="false">
...
</action>

<action **path="/auditor/otherInfo"** **type="org.sae.aab.struts.action.OtherInfoAction"**
            scope="request" name="OtherInfoForm" parameter="method" validate="false">
...
</action>

我已突出显示路径和类型以更集中。

我想知道路径,因为我想设置不同的参数并相应地重定向流程。

请帮帮我..

【问题讨论】:

    标签: java struts struts-1 url-mapping struts-config


    【解决方案1】:

    您可以从ActionMapping 获得它。动作映射在动作执行时作为参数传递给动作。

    String path = mapping.getPath();
    

    【讨论】:

      猜你喜欢
      • 2012-10-29
      • 2012-08-22
      • 2014-09-30
      • 1970-01-01
      • 1970-01-01
      • 2015-05-22
      • 1970-01-01
      • 1970-01-01
      • 2020-10-13
      相关资源
      最近更新 更多