快速业务通道

strtus之Titles框架应用 - 编程入门网

作者 佚名技术 来源 NET编程 浏览 发布时间 2012-06-17
r section --%> <td width="150" valign="top" align="left" bgcolor="#CCFFCC"> <tiles:insert page="sidebar.jsp" flush="true"/> </td> <%-- Main content section --%> <td height="100%" width="*"> <table width="100%" height="100%"> <tr> <%-- Header section --%> <td valign="top" height="15%"> <tiles:insert page="header.jsp" flush="true"/> </td> <tr> <tr> <%-- Content section --%> <td valign="top" height="*"> <tiles:insert page="productContent.jsp" flush="true"/></tr> <tr> <%-- Footer section --%> <td valign="bottom" height="15%"> <tiles:insert page="footer.jsp" flush="true"/> </td> </tr> </table> </td> </tr> </table> </body >

strtus之Titles框架应用(3)

时间:2011-04-09

以上虽然用到了<titles:insert>但是页面还是存在很多重复代码,可以采用 Tiles模版机制实现

Tiles 模板

通俗地讲,Tiles 模板是一种描述页面布局的JSP 页面。Tiles 模板只定义了Web 页面

的样式,而不指定内容。在Web 应用运行时,才把特定内容插入到模板页面中。同一模板

可以被多个Web页面共用。

使用模板,可以轻松地实现Web 应用的所有页面保持相同的外观和布局,而无需为每

个页面硬编码。在一个应用中,大多数页面使用同一个模板,某些页面可能需要不同的外

观,而使用其他的模板,因此一个应用可能有一个以上的模板。

以下是在tilestaglibs应用中使用Tiles模板的步骤。

(1)安装Tiles标签库所需的文件.

(2)在web.xml文件中配置<taglib>元素.

(3)定义模板文件

例layout.jsp

<%@ page contentType="text/html; charset=UTF-8" %> <%@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles"%> <html> <head> <title>TilesTaglibs Sample</title> </head> <body > <%-- One table lays out all of the content --%> <table width="100%" height="100%"> <%-- Sidebar section --%> <tr> <td width="150" valign="top" align="left" bgcolor="#CCFFCC"> <tiles:insert attribute="sidebar"/> </td> <%-- Main content section --%> <td valign="top" height="100%" width="*"> <table width="100%" height="100%"> <tr> <%-- Header section --%> <td height="15%"> <tiles:insert attribute="header"/> </td> <tr> <tr> <%-- Content section --%> <td valign="top" height="*"> <tiles:insert attribute="content"/> </td> </tr> <tr> <%-- Footer section --%> <td valign="bottom" height="15%"> <tiles:insert attribute="footer"/> </td> </tr> </table>

凌众科技专业提供服务器租用、服务器托管、企业邮局、虚拟主机等服务,公司网站:http://www.lingzhong.cn 为了给广大客户了解更多的技术信息,本技术文章收集来源于网络,凌众科技尊重文章作者的版权,如果有涉及你的版权有必要删除你的文章,请和我们联系。以上信息与文章正文是不可分割的一部分,如果您要转载本文章,请保留以上信息,谢谢!

分享到: 更多

Copyright ©1999-2011 厦门凌众科技有限公司 厦门优通互联科技开发有限公司 All rights reserved

地址(ADD):厦门软件园二期望海路63号701E(东南融通旁) 邮编(ZIP):361008

电话:0592-5908028 传真:0592-5908039 咨询信箱:web@lingzhong.cn 咨询OICQ:173723134

《中华人民共和国增值电信业务经营许可证》闽B2-20100024  ICP备案:闽ICP备05037997号