STRUTS2 Model Driving principle __ Drive Model

Source: Internet
Author: User

Before you talk about model-driven, take a look at attribute-driven, attribute-driven, and models that are used to resolve the value of a form and the values of a property in a class.

One, attribute driven

A) Principle: mainly depends on the Parameterinterceptor interceptor to achieve the form value and action in the corresponding properties of the value transfer, Valuestack.setvalue () method operation value Stack.

b) Form:

I. Set properties in action that have the same name as the Name property in the page form and must have set and get methods.

Ii. Note: If the attribute-driven and model-driven property names are duplicated, only the model driver can fetch the value, and the property-driven value is null.

c) schematic diagram:


A) Example:

I. JSP pages are as follows:


The action is as follows:



First, model driven

A if there's a lot of content in the JSP page form, attribute-driven action classes need to write many attributes and corresponding sets and get methods that affect the readability of the main processes in the action, so that the corresponding attributes of the form are placed in a specialized javabean to form an entity class.

b) Model driven

I.action class:


Entity classes:









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.