How can I get the forward path in Struts

60 Views Asked by At

In the below mentioned Project I want to retrieve below mentioned forward path marked in Yellow. Is it possible?
enter image description here

I have tried to do this - String af = mapping.getPath();

But this actually returns the below mentioned marked in Yellow.
enter image description here

I tried using mapping.getPath();

But it's actually returning Action path instead of the Forward path.

1

There are 1 best solutions below

0
Roman C On

To get the forward path from the action config you can use Struts API.

ActionMapping::findForward() returns the ForwardConfig object mapped to the action config or a global forward.

Find and return the ForwardConfig instance defining how forwarding to the specified logical name should be handled. This is performed by checking local and then global configurations for the specified forwarding configuration. If no forwarding configuration can be found, return null.

Now, you can get the forward by name

ActionForward forward = mapping.findForward("hello1");
String path = forward.getPath();