In my Struts application, I need to create an endpoint (URL) which simply tells the user's browser to redirect to an external URL.
It looks like this can be done by creating a new Action class and defining a new <result type='redirect'> result, but that seems like overkill. I don't need an Action class to do any kind of processing on my end, just a simple redirect.
Is there a way I can set up an endpoint simply with a line or two in a configuration file?
You can create the endpoint using an action configuration and without the
Actionclass. Then add aredirectresult type. You can use it with any package that extends astruts-default.You can see more details here.
To use slashes in action name you should use these constants
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.