You can create the endpoint using an action configuration and without the Action
class. Then add a redirect
result type. You can use it with any package that extends a struts-default
.
<package name="default" namespace="/" extends="struts-default">
<action name="redirect_to_outside_website/*">
<result type="redirect">{1}</result>
</action>
</package>
You can see more details here.
To use slashes in action name you should use these constants
<constant name="struts.enable.SlashesInActionNames" value="true"/>
<constant name="struts.mapper.alwaysSelectFullNamespace" value="false"/>
The example above can redirect to any URL using a wildcard mapper (which is a default mapper in Struts 2). If you need to fix the URL in the configuration file, then you can place a fixed URL directly to the <result>
tag.
<package name="default" namespace="/" extends="struts-default">
<action name="redirect_to_outside_website">
<result type="redirect">https://server_domain/my_fixed_location</result>
</action>
</package>