首页
论坛
图书
开发资料
在线文档
网址
下载
联系我们
 新闻│Java│JavaScript│Eclipse│Eclipse 英文│J2EE│J2ME│J2SE│JSP│Netbeans│Hibernate│JBuilder│Spring│Struts
站内搜索: 请输入搜索关键词

当前页面: 开发资料首页 → Java 专题 → struts中使用tiles组件

struts中使用tiles组件

摘要: struts中使用tiles组件

</td> </tr> <tr> <td width="521" height="35" valign="top" class="ArticleTeitle"> 1.在你的struts配置文件struts-config.xml中加入下面的配置:




2.生成tiles-def.xml文件:
<?xml version="1.0" encoding="ISO-8859-1" ?>

tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd">

















3.生成layout.jsp布局文件:
<%@ page contentType="text/html; charset=GBK" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles"%>

<head> 布局设计 </head>
<body >
<table width="100%" height="100%">
<tr>
<td width="150" valign="top" align="left" bgcolor="#CCFFCC">

</td>
<td valign="top" height="100%" width="*">
<table width="100%" height="100%">
<tr> <td height="15%"> </td> </tr>
<tr> <td valign="top" height="*"> </td></tr>
<tr> <td valign="bottom" height="15%"></td></tr>
</table>
</td>
</tr>
</table>
</body>

4.生成要使用的JSP文件sidebar.jsp,header.jsp,footer.jsp。

5.通过action-mappings配置你的tiles组件:

parameter="index-definition">


parameter参数的值,是你在tiles-def.xml文件里某个的define的name。

6.别忘了在web.xml中加入

/tags/struts-tiles
/WEB-INF/struts-tiles.tld


同时还要保证你使用的是struts 1.1版本。
现在就可以动手为你的项目加入tiles应用了。
完成以上步骤,完成Tomcate部署并启动,通过http://127.0.0.1:8080/strutsTiles/index.do
可以看到效果. 运行下面两个文件是同样的效果:

1、index1.jsp
<%@ page contentType="text/html; charset=gb2312" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>
使用逻辑名


2、index.jsp

<%@ page contentType="text/html; charset=gb2312" %>
<%@ taglib uri="/tags/struts-tiles" prefix="tiles" %>





function TempSave(ElementID) { CommentsPersistDiv.setAttribute("CommentContent",document.getElementById(ElementID).value); CommentsPersistDiv.save("CommentXMLStore"); } function Restore(ElementID) { CommentsPersistDiv.load("CommentXMLStore"); document.getElementById(ElementID).value=CommentsPersistDiv.getAttribute("CommentContent"); } </td> <td width="163" valign="top" class="ArticleTeitle">
</td> </tr> <tr> <td height="25" colspan="2" valign="top" class="ArticleTeitle">


↑返回目录
前一篇: Struts中DispatchAction类的使用
后一篇: Struts-config.xml配置文件讲解

首页 | 全站 Sitemap | 联系我们 | 设为首页 | 收藏本站
版权所有 Copyright © 2006-2007, Java 编程资料牛鼻站, All rights reserved