Struts uses Tiles auxiliary development

zhaozj2021-02-12  151

Struts uses Tiles auxiliary development

For the layout management of the page, Tiles is well done so that we think is very smooth during the development process, especially in the process of developing the Struts development project, often with Tiels to assist in the development, effect.

If you want to see the detailed documentation of Tiles, please visit http://www.lifl.fr/~dumoulin/tiles/

Here I want to talk about my own experience from the way:

In one of our projects, most of the layouts of the page are the same, and if we pay the same style page as a class, this classification will not be much. (How is the classification of different projects, and whether the page style planning is highly efficient

Suppose we propose a type of page (such as product management), the layout is as follows:

Then we can define such a total type in Tiles-Defs.xml, as follows:

TILES-Defs.xml is placed in / YourWebApp / Web-INF /

DOCTYPE TILES-Definitions PUBLIC

"- // Apache Software Foundation // DTD TILES Configuration 1.1 // en"

"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">

......

......

......

The above defines a layout type, assuming that the A layout is named, and the following is the layout method that belongs to this type of style.

Add product pages, and ultimately we have to care about the addproducts.jsp this page, but how do we use a layout layout style?

as follows:

... connected to Tiles-Defs.xml ...

......

......

The above is only illustrated by a layout type, and other layout types (such as layout B, layout C .....) are expanded in communication with communication, there is nothing difficult.

Below, the following is a configuration in Struts-Config.xml, in Struts1.1 Tiles is the use of Struts's extension mechanism to complete the load, the code is simple as follows:

Struts-config.xml

......

Value = "/ Web-inf / tiles-defs.xml" />

If you have multiple TILES configuration files, then "," is separated.

Here is a write mapping after using TILES.

If we want to add a request to add goods, you must perform the loading of the product type first in the addition of the page:

AddProductAction.do -> ProductAction -> addproducts.jsp

ProductAction Complete the collection of product types Back to the client

Struts-config.xml

..........

TYPE = "com. ***. ProductAction">

..........

Ok, the above processes use TILES for a brief description, and the specific Tiles documents are given to the connection given above.

The Struts release package also has a TILSE documentation and example.

转载请注明原文地址:https://www.9cbs.com/read-6097.html

New Post(0)