First intimate contact with the tiles framework

Source: Internet
Author: User

I. How to Use the tiles framework
1. Add a jar package. Struts has been integrated.
2. Configure the plus-In attribute in Struts-config
3. Configure the taglib attribute in Web. xml and configure the tiles tag.
4. Write tiles profile tiles-def.xml
5. According to the tiles-def.xml write layout, the layout is actually a. jsp, but contains the tiles: insert
6. Write the page
7. Different jump methods: 1) Add a new page (Two JSPs are required for each page, one calling page and one page in the Framework)
2) use the paremeter attribute of action.

 

2. Notes for using the tiles framework:
1. The definitions-config attribute in the plus-In attribute specifies the tiles configuration file. You can specify multiple
2. combination in the tiles configuration file
<Definition name = "base-definition" Path = "/layout. jsp">
<Put name = "sidebar" value = "sidebar. jsp"/>
<Put name = "Header" value = "header. jsp"/>
<Put name = "content" value = ""/>
<Put name = "footer" value = "footer. jsp"/>
</Definition>

<Definition name = "index-definition" extends = "base-definition">
<Put name = "content" value = "indexcontent. jsp"/>
</Definition>
In this way, each time you add a new page similar to indexcontent, you only need to configure a new definition inherited from base-definition.
3. The main page and the content page in the layout are different concepts. The main page only needs to have such a few words.
<% @ Page contenttype = "text/html; charset = gb2312" %>
<% @ Taglib uri = "http://jakarta.apache.org/struts/tags-tiles" prefix = "tiles" %>
<Tiles: insert definition = "index-definition"/>
The definition attribute specifies the configuration in tiles to be used.
The content page can be written without considering the template.
4. The two different usage methods are not clear yet. However, tiles is really useful.

Iv. Advantages and disadvantages of the frame structure currently used by tiles and departments:
To be honest, compared with the use of the framework structure, it is still troublesome, and it will increase the number of JSP. However, the Department's frame framework is actually quite fragile. If you directly enter a URL in the address bar, the framework will no longer exist. This is very dangerous. Tiles makes up for this deficiency.
Check whether two things can be used together.
 

Related Article

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.