想写个struts
2.0+tiles模版玩玩,没有想到找资料还麻烦,于是自己把通宵弄好的过程记下来,以供大家有急需,不足的地方欢迎交流。
1.在WEB-INF/lib下加入所需的jar包
commons-digester-1.6.jar,
tiles-core-2.0-20070207.130156-4.jar,
tiles-api-2.0-20070207.130156-4.jar,
struts2-tiles-plugin-2.0.6.jar,
struts2-core-2.0.6.jar
xwork-2.0.1.jar,
2. 以下内容添加到web.xml
<
context-param
>
<
param-name
>
org.apache.tiles.CONTAINER_FACTORY
</
param-name
>
<
param-value
>
org.apache.struts2.tiles.StrutsTilesContainerFactory
</
param-value
>
</
context-param
>
<
context-param
>
<
param-name
>
org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
</
param-name
>
<
param-value
>
/WEB-INF/tiles.xml
</
param-value
>
</
context-param
>
<
listener
>
<
listener-class
>
org.apache.struts2.tiles.StrutsTilesListener
</
listener-class
>
</
listener
>
3.在WEB-INF下添加和tiles.tld和tiles.xml文件,其中tiles.tld内容为tiles-core-
2.0-20070207.130156-4.jar包中META_INF/tiles-core.tld的内容。
tiles.xml内容:
<?
xml
version
=
"1.0"
encoding
=
"GB2312"
?>
<!
DOCTYPE
tiles-definitions
PUBLIC
"-//Apache Software
Foundation//DTD Tiles Configuration 2.0//EN"
"http://jakarta.apache.org/struts/dtds/tiles-config.dtd"
>
<
tiles-definitions
>
<
definition
name
=
"myapp.homepage"
template
=
"layout.jsp"
>
<
put
name
=
"title"
value
=
"Tiles tutorial homepage"
/>
<
put
name
=
"header"
value
=
"/tiles/header.jsp"
/>
<
put
name
=
"menu"
value
=
"/tiles/menu.jsp"
/>
<
put
name
=
"body"
value
=
"/tiles/cBody.jsp"
/>
<
put
name
=
"footer"
value
=
"/tiles/footer.jsp"
/>
</
definition
>
</
tiles-definitions
>
4.struts.xml 为:
<!
DOCTYPE
struts
PUBLIC
"-//Apache Software
Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd"
>
<
struts
>
<
package
name
=
"default"
extends
=
"tiles-default"
>
<action name="go"
class="com.action.MyAction">
<!--result
name="success">/next.jsp</result-->
<
result
name
=
"success"
type
=
"tiles"
>
myapp.homepage
</
result
>
</
action
>
</
package
>
</
struts
>
红色部分根据自己项目
定。注意
extends
=
"tiles-default"
5创建layout.jsp
:
<%@
page
contentType
=
"text/html;
charset=UTF-8"
%>
<%@
taglib
uri
=
"WEB-INF/tiles.tld "
prefix
=
"tiles"
%>
<
html
>
<
head
>
<
title
></
title
>
</
head
>
<
body
>
<
table
width
=
"768px"
height
=
"800px"
border
=
"2"
align
=
"center"
>
<
tr
>
<
td
colspan
=
"2"
align
=
"center"
valign
=
"top"
width
=
"768px"
height
=
"100px"
bgcolor
=
"#80ff80"
>
<
tiles:insertAttribute
name
=
"header"
/>
</
td
>
</
tr
>
<
tr
>
<
td
align
=
"center"
width
=
"150px"
height
=
"800px"
bgcolor
=
"#00ff00"
>
<
tiles:insertAttribute
name
=
"menu"
/>
</
td
>
<
td
align
=
"right"
width
=
"618px"
height
=
"800px"
bgcolor
=
"#ff80c0"
>
<
tiles:insertAttribute
name
=
"body"
/>
</
td
>
</
tr
>
<
tr
>
<
td
colspan
=
"2"
bgcolor
=
"#00ff40"
height
=
"100px"
>
<
tiles:insertAttribute
name
=
"footer"
/>
</
td
>
</
tr
>
</
table
>
</
body
>
</
html
>
6.
根据
<
put
name
=
"title"
value
=
"Tiles tutorial
homepage"
/>
<
put
name
=
"header"
value
=
"/tiles/header.jsp"
/>
<
put
name
=
"menu"
value
=
"/tiles/menu.jsp"
/>
<
put
name
=
"body"
value
=
"/tiles/cBody.jsp"
/>
<
put
name
=
"footer"
value
=
"/tiles/footer.jsp"
/>
在
WebRoot
下创
建
tiles
目录和相应
jsp
文件
分享到:
相关推荐
stauts2.0整合tiles 框架 stauts2.0整合tiles 框架 stauts2.0整合tiles 框架 stauts2.0整合tiles 框架 stauts2.0整合tiles 框架 例子代码
过程介绍在我的Csdn Blog
struts2.0中使用Tiles框架所需jar包之一
Struts-2.1.6整合Tiles2全攻略
struts2的tiles配置
struts2.0的标签学习 关键字: struts2 标签 用过struts1.x的人都知道,标签库有html、bean、logic、tiles, 而struts2.0里的标签却没有分类,只用在jsp头文件加上 <%@ taglib prefix="s" uri="/struts-tags" %> ...
很好的struts2入门教程,网上搜集整理的! 内容: ·常用的Struts 2.0的标签(Tag)介绍 ·Struts 2.0的Action讲解 ·Struts2国际化(i18n)您的应用程序 ·Struts2.0转换器(Converter... ·完全Struts's Tiles入门
集成 Struts、Tiles 和 JavaServer Faces.doc
struts2 tiles2配置的例子
体验Struts2和tiles的神奇结合。
struts2-tiles-plugin-2.1.6.jar
NULL 博文链接:https://customme.iteye.com/blog/755914
struts2集成tiles2.myeclipse10
struts2.0中使用Tiles框架所需jar包之二
这个用途不大,送大家了........我不怎么喜欢
struts资料\Tiles框架--页面布局
NULL 博文链接:https://hxskwk.iteye.com/blog/697935
struts2.0中使用Tiles框架所需jar包之三
在开发中经常使用的sturts中的tiles模板,是页面看起来更加的合理,减少页面的组合,需要使用的jar包,缺一不可。