Reputation: 5163
I am moving from struts1 to struts2 and I have successfully created simple applications in struts2 I want to use unspecified / custom functions of Dispatchaction class which i used in struts1 in struts2 , which class would be extended to do this
Upvotes: 0
Views: 2360
Reputation: 23587
DispatchAction
helps us in grouping a set of related functions into a single action. In Struts 2 all the Actions by default provide this functionality. To use this functionality we need to create different methods with the similar signature of the execute() method, only the name of the method changes.
for e.g you can create a Action for User handling which includes method like create,delete update user etc
public class UserAction extends ActionSupport{
private String methodName;
public String execute()
{
methodName= "Inside execute method";
return SUCCESS;
}
public String add()
{
methodName= "Inside add method";
return SUCCESS;
}
public String update()
{
methodName= "Inside update method";
return SUCCESS;
}
}
Upvotes: 1
Reputation: 160191
No class would be extended; use the "method" attribute in the action configuration, or annotate the method directly if using annotation-based configuration. You can also use wildcard actions to avoid manual configuration.
If that doesn't work for you, please explain specifically what your needs are, and why that won't work.
Upvotes: 1