The model-driven concept is not directly related to the com. opensymphony. xwork. modeldriven interface.

Source: Internet
Author: User

2. model-driven (model-driven) action. Action exposes a model class through the get method. form fields correspond to the attributes of the model class. The model-driven concept is not directly related to the com. opensymphony. xwork. modeldriven interface. Our action does not implement the com. opensymphony. xwork. modeldriven interface or model-driven. For example:

Java code
  1. User. Java
  2. Public ClassUser {
  3. PrivateString username;
  4. PrivateString password;
  5. PrivateString email;
  6. ......
  7. Get ();/set (); Method
  8. ..........
  9. }
  10. Registeraction. Java
  11. Public ClassRegisteractionImplementsAction {
  12. PrivateUser user =NewUser ();;
  13. PublicString execute ();ThrowsException {
  14. // Perform User Registration
  15. }
  16. PublicUser getuser ();{
  17. ReturnUser;
  18. }
  19. }
  20. Page register.html contains:
  21. ......
  22. <Input name = "user. username">
  23. .......
User. java public class user {private string username; private string password; private string email ;...... get ();/set (); Method ..........} registeraction. java public class registeraction implements action {private user = new user (); Public String execute (); throws exception {// execute user registration operation} public user getuser (); {return user ;}} page register.html contains :...... <input name = "user. username "> .......

Model-driven accesses data through the ognl Expression Language. For example, during registration, the expression language user. username will execute getuser. setusername (). So what is the com. opensymphony. xwork. modeldriven interface? It puts the model obtained by the object GetModel () in valuestack. It can be understood that the attribute of this model is appended to the action. It is mainly used to implement the formbean function similar to struts. Conclusion: If model-driven (model-driven) action is considered to be com. opensymphony. xwork. the modeldriven interface is incorrect. model-driven and COM. opensymphony. xwork. the modeldriven interface has no direct relationship. In practical applications, we generally use model-driven and field-driven together, and do not need to completely distinguish these two concepts.

 

1. field-driven (field-driven) action. Action has its own attributes. These attributes are generally the basic types of Java. The form field corresponds directly to the action attribute.

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.