How do you create an action in struts2 that uses multiple methods in different classes?
So for example I would like something like this but I’m pretty sure this doesn’t work:
<action name="person_create" method="personCreate, carCreate" class="PersonActionBean, CarActionBean">
<result name="success">index.jsp</result>
</action>
To be specific, I’m using struts 2.1.8.1
PersonAction.java – personCreate():
Person person = new Person();
CarAction.java – carCreate():
Car car = new Car();
There are two variable:
1: why are you willing to call 2 actions, from the concept of MVC, you shouldn’t do this, if you wanna process to different objects, you should build a new layer(e.g. interface, or service layer) to do this.
2: if you have to do this, you can define a new action, which using the
chainresult type to call them all. here is the Chain result type, but be careful.