You can do it using wildcard mappings and associating your validation rules with your single action class:
Wildcard Mappings
In your struts.xml, define an action like so:
<action name="user-*" class="DoSomething" method="{1}" >
<result name="input">/WEB-INF/{1}.jsp</result>
<result name="success">/WEB-INF/{1}-success.jsp</result>
</action>
Then you can invoke the DoSomething
action class with either of these two URLs:
http://yourapp.com/user-login.action
http://yourapp.com/user-details.action
The result will be that the part of the request after the hyphen ("login" or "details") will replace the {1}
in your action definition. Therefore the first URL will invoke the DoSomething.login()
method, go to the login.jsp on INPUT or the login-success.jsp on SUCCESS.
All you have to do is define login()
and details()
methods in DoSomething
class.
Validation Rule Association
To associate validation rules with your DoSomething
action class, simply name the .xml file containing them DoSomething-validation.xml. Since both user-login and user-details requests use that class, the rules will be run for both of them.