Use tiles Concise Manual in struts

Source: Internet
Author: User
Tags tld
To use tiles in struts, ensure that the page correctly introduces the struts-tiles.tld, that is, <% @ taglib uri = "/tags/Struts-tiles" prefix = "tiles" %>. In addition, the struts-config.xml configuration is as follows:
<Plug-in classname = "org. Apache. Struts. Tiles. tilesplugin">
<! -- Path to XML definition file -->
<Set-Property = "definitions-config" value = "/WEB-INF/tiles-defs.xml"/>
<! -- Set Module-awareness to true -->
<Set-Property = "moduleaware" value = "true"/>
</Plug-in>
<Controller processorclass = "org. Apache. Struts. Tiles. tilesrequestprocessor"/>
In
// Define a motherboard
<Definition name = ". mainlayout" Path = "/common/layouts/classiclayout. jsp">
<Put name = "title" value = "Sample page title"/>
<Put name = "Header" value = "/common/header. jsp"/>
<! -- Put name = "menu" value = ". mainmenu"/-->
<Put name = "footer" value = "/common/footer. jsp"/>
<Put name = "body" value = ""/>
</Definition>
In the classiclayout. jsp file:
<% @ Page contenttype = "text/html; charset = UTF-8" Language = "Java" %>
<! -- % @ Taglib uri = "/WEB-INF/struts-tiles.tld" prefix = "tiles" % -->
<% @ Taglib uri = "/tags/Struts-tiles" prefix = "tiles" %>
<HTML>
<Head> <title> simple JSP page </title> <Body bgcolor = "# ffffff" text = "#000000" link = "#023264" alink = "#023264" vlink = "#023264">
<Table border = "0" width = "100%" cellspacing = "5">
<Tr>
<TD colspan = "2"> <tiles: insert attribute = "Header"/> </TD>
</Tr>
<Tr>
& Lt; TD width = "140" valign = "TOP" & gt;
<! -- Tiles: insert attribute = 'menu '/-->
</TD>
<TD valign = "TOP" align = "Left">
<Tiles: insert attribute = 'body'/>
</TD>
</Tr>
<Tr>
<TD colspan = "2">
<Tiles: insert attribute = "footer"/>
</TD>
</Tr>
</Table>
</Body>
</Html>

// Define the child board, which inherits the parent board through extends
<Definition name = "ordertiles" extends = ". mainlayout">
<Put name = "body" value = "/pages/order. jsp"/>
</Definition>
// Define an action that directs to the tiles template.
<Action Path = "/ordertiles" type = "org. Apache. Struts. Actions. forwardaction" parameter = "ordertiles"> </Action>
// Define an action, whose forward path is an action containing the tiles Template
<Action Path = "/editorder" type = "heroking. Action. editorder"
Name = "orderform" Scope = "request"
Validate = "false">
<Forward name = "success" Path = "/ordertiles. Do"/>
</Action>
<Action Path = "/submitorder" type = "heroking. Action. submitorder"
Name = "orderform" Scope = "request"
Validate = "false">
<Forward name = "success" Path = "/ordertiles. Do"/>
</Action>
You can.

 

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.