1.ForwardAction: for request forwarding.
For example: anchor points, in order to maintain the structure of MVC, in the use of Anchor point tag is not directly jump page, but by jumping to xx.do by Forwardaction implementation page jump.
Configuration:
<action-mappings>
<action path= "/tologin" type= "org.apache.struts.actions.ForwardAction " forward= "/login.jsp" >
</action>
</action-mappings>
The Forward property value is the page to jump.
2.incluedeAction: Used to include pages.
Jsp: <jsp:include page= "includewelcome.do" ></jsp:include>
Configuration:
<action-mappings>
<action path= "/includewelcome" type= "org.apache.struts.actions.IncludeAction" parameter= "/welcome.jsp" >
</action>
</action-mappings>
3.DispatchAction: Used to implement a set of related business in a class (multiple submit buttons for one form on the same page).
Usage: Write a class to inherit dispatchaction, but remember that you cannot override the Dispatchaction Execute () method. The return value type of the business method, the type of parameter passed and the number of arguments consistent with the execute () method.
defect: To use the JS code, if JS is disabled, you can not achieve the relevant business.
JSP page:
<form action= "train.do" method= "POST" >
<input type= "hidden" name= "Training" >
<input type= "Submit" value= "feed" name= "eatbtn" onclick= "training.value=" Eat " />
<input type= "Submit" value= "storytelling" name= "talkbtn" onclick= "training.value=" Talk "/>
<input type= "Submit" value= "Game" name= "playbtn" onclick= "training.value=" Play ' " />
</form>
After clicking the button, the value of the hidden form submission must be consistent with the method name of the business method in Dispatchaction.
Configuration:
<action path= "/train" type= "com.lovo.struts.action.PetDispatchAction " parameter= "Training" >
<forward name= "Petinfo" path= "/petinfo.jsp" ></forward>
</action>
4.MappingDispatchAction: For multiple forms one action processing (separate pages, processing a business).
Usage: Write a class to inherit mappingdispatchaction, but remember that you cannot override the Mappingdispatchaction Execute () method. The return value type of the business method, the type of parameter passed and the number of arguments consistent with the execute () method.
JSP:
<form method= "POST" action= "add.do" name= "AddForm" >
<input type= "Submit" value= "Add" name= "addbtn" >
</form>
<form method= "POST" action= "del.do" name= "Delform" >
<input type= "Submit" value= "del" name= "DELBTN" >
</form>
Configuration:
<action path= "/add" type= "com.lovo.struts.action.MyMappingDispatchAction " parameter= "Addstu" >
</action>
<action path= "/del" type= "com.lovo.struts.action.MyMappingDispatchAction " parameter= "Delstu" >
</action>
the property value of the parameter property must be consistent with the method name of the business method in Mappingdispatchaction.
5.
lookupdispatchaction:
used to implement a set of related business in a class (multiple submit buttons for a form on the same page).
Usage: Write a class to inherit mappingdispatchaction, but remember not to rewrite
lookupdispatchaction
the Execute () method. The return value type of the business method, the type of parameter passed and the number of arguments consistent with the execute () method. Rewrite
Getkeymethodmap () method. You must configure a Form-bean.
JSP page:
<input type= "hidden" value= <%= ID%> name= "petid" > when using
lookupdispatchaction, the JSP page uses the Struts HTML tag library and the Bean Tag library. As well as the Propperties configuration file. html tag
the value of the property must be the same.
The value of the key for the HTML tag corresponds
the value in the propperties.
Configuration:
<form-bean name= "lookup" type= "Org.apache.struts.action.DynaActionForm" ></form-bean>
<action path= "/train" type= "com.lovo.struts.action.PetLookupDispatchAction" name= "Lookup" parameter= " Playbtn ">
<forward name= "Petinfo" path= "/petinfo.jsp" >
</forward>
</action>
the value of the parameter property must be the same as
of HTML tags
the value of the property is consistent.
6.SwitchAction: Used for page jumps between multiple profiles.
Configuration in xml:
<init-param>
<param-name>config/t87</param-name>
<param-value>/WEB-INF/struts-moduleA.xml</param-value>
</init-param>
configuration in Struts-config.xml:
<action path= "/tot87" type= "org.apache.struts.actions.SwitchAction" >
Struts1 action inherits different parent classes that have different effects