Today, when we make a billing move, we use the modeldriver of struts2 to receive the data submitted by the user, which is associated with the user Details table, telephone information table, package information table, and administrator information table; the submitted data includes phone numbers, user detailed addresses and personal information, package names, and package types ,,,
@ Entitypublic class user {private int ID; private string username; private string password; private string type; private string status; private int counter; private date radate; private customer customerid; // user details private phone phoneid; // phone information private pack packid; // package details private manager managerid; // which administrator has entered the private int currentphone; private int currentmassage; private int currentdata;
When the user model is used to receive data, it never receives data. After reading a lot of articles online, it still cannot find a solution. If properties are used to receive data, there are too many codes in the entire useraction controller to be directly looked.
Suddenly, I thought of using the data transmission object DTO class (Data Transport object) and some people call it pojo, no matter what it is called; it means to build a simple JavaBean, this is used to transmit data;
Create a useradddto class for the user, write the required data attributes (Note: The property names and attribute types must be consistent), and generate the setter/getter method.
Public class useradddto {private string username; private string password; private string type; private string realname; private string mobilephone; private string packname; private string status; private string customerid; // <span style = "color: # ff0000;"> do not use the int type. Otherwise, data cannot be received. </span> private string counter; private string phoneid; private string packid; private string managerid;
Finally, a new object in useraction is generated and the setter/getter method is generated.
private UserAddDTO addDTO = new UserAddDTO();
public UserAddDTO getAddDTO() {return addDTO;}public void setAddDTO(UserAddDTO addDTO) {this.addDTO = addDTO;}
Once again, you can accept the data submitted from multiple tables !!! Try it !!