Multiple submission of struts2 forms (Annotation Mode)

Source: Internet
Author: User

Multiple submission of struts2 forms (Annotation Mode)


Assume that a form has several operations (update, delete, create etc.) and can be submitted to action by method. There is a lot of information on the Internet, which describes how to implement multiple submissions through xml configuration. This document is submitted by annotation.


Form:

[Html]
<S: fielderror/>
<S: form action = "saveFloorroomdetail" namescapse = "/setup">
<Table>
<Tr>
<Td>
<Input type = "text" name = "name1" value = "value1">
</Td>

<Td>
<Input type = "text" name = "name2" value = "value2">
</Td>
<Tr>
 
<Tr>
<Td align = "center" colspan = "2" height = "60">
<S: submit key = "button. save" method = "save"/>

<S: submit key = "button. delte" method = "delete"/>
</Td>
</Tr>
</Table>
</S: form>

Java code:

[Java]
@ ParentPackage (value = "setup ")
Public class MutipleSubmitAction extends BaseAction {
Private String name1;
Private String name2;
 
Public String getName1 (){
Return name1;
} Www.2cto.com
 
Public void setName1 (String name1 ){
This. name1 = name1;
}
 
Public String getName2 (){
Return name2;
}
 
Public void setName2 (String name2 ){
This. name2 = name2;
}
 
 
@ Actions ({
@ Action (value = "/saveFloorroomdetail", results = {
@ Result (location = "detail_result.jsp", name = "success "),
@ Result (location = "detail. jsp", name = "input "),
@ Result (location = "detail. jsp", name = "delete "),
})
})
Public String save (){
System. out. println ("invoke save ()");
Return SUCCESS;
}

 
Public void validateSave (){
System. out. println ("validate Save ");
}

Public String delete (){
System. out. println ("invoke delete ()");
Return "delete ";
}
}

Note:
The String value returned by the delete () and save () Methods corresponds to the name in annotation @ Result. ValidateSave () is the Save () method verified before the form is submitted.


 

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.