简体   繁体   中英

How to access path attribute of action tag (struts-config.xml) in Action or dispatch action class?

I am using unspecified method of DispatchAction and there is a situation where I need to know the contents of the path attribute of action tag in struts-config.xml, because this Action class is being used for two action paths.

eg:

<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>

I have highlighted path and type for more focussing.

I wanted to know the path because I wanted to set different parameters and redirect the flow accordingly.

help me please..

You can get it from ActionMapping . The action mapping is passed to the action as parameter when it executes.

String path = mapping.getPath();

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM