struts2+tiles环境搭建
2011-05-10 17:59
302 查看
1. base jars for struts2:
2. jars for tiles:
3. Put tiles-jsp.tld under WEB-INF and create file tiles.xml (tiles definition) in WEB-INF
tiles.xml
<tiles-definitions>
<definition name="ibeidou.mainLayout" template="/layout.jsp">
<put-attribute name="title" value="welcome to struts2" />
<put-attribute name="contant" value="/main.jsp" /><!-- '/' is must-->
<put-attribute name="footer" value="/footer.jsp" />
</definition>
</tiles-definitions>
layout.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><tiles:getAsString name="title" /></title>
</head>
<body>
<tiles:insertAttribute name="contant"></tiles:insertAttribute>
<hr></hr>
<tiles:insertAttribute name="footer"></tiles:insertAttribute>
</body>
</html>
4. In struts.xml
<package name="mytiles" extends="tiles-default"> but no longer
<package name="myaction" extends="struts-default"><!-- The package name should be unique -->
<action name="welcome" class="com.ibeidou.struts2.test01.HelloAction">
<result name="success" type="tiles">ibeidou.mainLayout</result>
</action>
5. web.xml add tiles listener
<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>
2. jars for tiles:
3. Put tiles-jsp.tld under WEB-INF and create file tiles.xml (tiles definition) in WEB-INF
tiles.xml
<tiles-definitions>
<definition name="ibeidou.mainLayout" template="/layout.jsp">
<put-attribute name="title" value="welcome to struts2" />
<put-attribute name="contant" value="/main.jsp" /><!-- '/' is must-->
<put-attribute name="footer" value="/footer.jsp" />
</definition>
</tiles-definitions>
layout.jsp
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1">
<title><tiles:getAsString name="title" /></title>
</head>
<body>
<tiles:insertAttribute name="contant"></tiles:insertAttribute>
<hr></hr>
<tiles:insertAttribute name="footer"></tiles:insertAttribute>
</body>
</html>
4. In struts.xml
<package name="mytiles" extends="tiles-default"> but no longer
<package name="myaction" extends="struts-default"><!-- The package name should be unique -->
<action name="welcome" class="com.ibeidou.struts2.test01.HelloAction">
<result name="success" type="tiles">ibeidou.mainLayout</result>
</action>
5. web.xml add tiles listener
<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>
相关文章推荐
- struts2+tiles环境搭建
- Struts2 环境搭建,版本号struts-2.3.15.1
- Spring3-hibernate3.3-struts2.1.8----环境搭建(1)
- Maven搭建Spring+Struts2+Mybatis项目(一) Maven环境
- Struts+Spring环境的搭建
- struts1学习之--2、struts环境的搭建
- Flex2与Struts整合配置-续搭建免费的flex开发环境flashdevelop
- Struts+spring+Hibernate+Mysql--环境搭建
- (转)Struts2+JFreeChart 环境搭建个基本用法!
- Struts2+Spring3+Mybatis3开发环境搭建
- mybatis3.3+struts2.3.24+mysql5.1.22开发环境搭建图文教程
- struts2+Hibernate4+spring3+EasyUI环境搭建之五:引入jquery easyui
- Struts2-2 Struts2.0概述与环境搭建
- SAStruts使用环境搭建运行tutorial project
- 基于struts环境下的jquery easyui环境搭建
- Struts原理及环境搭建
- Struts 2.1.6 搭建环境
- Struts(2)环境搭建
- Spring3-hibernate3.3-struts2.1.8----环境搭建(2)
- Hibernate环境搭建+struts整合