STRUTS2 Model Driven

Source: Internet
Author: User

 Public class extends Actionsupport implements modeldriven<user>  {    private User user = new user ();    Public User Getmodel () {        return   user;    }    @Override    Publicthrows  Exception {        System.out.println (user);         return NONE;}    }
<form action= "${pagecontext.request.contextpath}/user3.action" method= "POST" > User name <input type= "text" Name= " Username "/><br/> password <input type=" password "name=" password "/><br/><input type=" Submit "value= "Submit"/></form>

  

Page:

User name: <input type= "text" name= "username" ><br/>

Action:

public class ParamAction3 extends Actionsupport implements modeldriven<user>{

Private User user = new user ();

Public User Getmodel () {

return user;

}

}

Implementation modeldriven<t> must manually build the encapsulated object.

* Model-driven use is the most extensive. A separate interceptor is provided in the STRUTS2 to complete the model-driven encapsulation, and some of the structures in the Struts2 are designed around model-driven.

Compare the second and third ways:

* The third type uses more. The second is more flexible. The third model-driven approach can only be encapsulated into one entity object. The second way is encapsulated into different entities.

* The third way to provide interceptors:

<interceptor name= "Modeldriven" class= "Com.opensymphony.xwork2.interceptor.ModelDrivenInterceptor"/>

* The second package to different entities:

<input type= "text" name= "User.username" >

<input type= "text" name= "Product.price" >

STRUTS2 Model Driven

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.