First, how to use the tiles framework
1. Add jar package, struts has been integrated
2. Configure the plus-in properties in Struts-config
3. Configure the Taglib attribute in the Web.xml to match the tiles tag
4. Write Tiles configuration file Tiles-def.xml
5. According to Tiles-def.xml write layout, layout is actually a. JSP, but it contains Tiles:insert
6. Write page
7. Different ways to jump:
1 Add New page (each page needs to write two JSP, a call page, a frame in the page)
2 The Paremeter attribute with the action.
Second, the use of the tiles framework should be noted where:
The Definitions-config property in the 1.plus-in property specifies the tiles configuration file and can specify multiple
Composition relationships in 2.Tiles configuration files
<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>
This way, each time you add a new page like indexcontent, you just need to configure a new inherited from base-definition definition to be OK
3. The content pages in the keynote page and layout are different concepts. The keynote page only needs to have so many words on OK
<%@ page contentType="text/html; charset=gb2312" %>
<%@ taglib uri="http://jakarta.apache.org/struts/tags-tiles" divfix="tiles"%>
<tiles:insert definition="index-definition"/>
Where the definition attribute specifies which configuration in the tiles to use
The content page can be completely regardless of the template problem, directly how to write, how to write.
4. Two different ways of using it are still not clear. But tiles is really good.
Third, the advantages and disadvantages of tiles:
To be honest, it's more cumbersome than using a frame structure, and it increases the number of JSPs. However, compared with the frame frame now used, it is relatively safe. The frame frame now used if you enter a URL directly in the address bar will cause the framework to cease to exist. This is very dangerous. and tiles just to make up for this problem.