[list]
[*][b][color=green]Package Explorer[/color][/b]
[/list]
[img]http://dl2.iteye.com/upload/attachment/0100/6418/dbdfe4ca-7081-3ff0-b110-ce55cc8b1e04.png[/img]
[list]
[*][b][color=green]Result[/color][/b]
[/list]
[img]http://dl2.iteye.com/upload/attachment/0100/6420/53a1b76a-90f7-3424-a321-a2622b112c42.png[/img]
[list]
[*][b][color=green]pom.xml[/color][/b]
[/list]
[list]
[*][b][color=green]web.xml[/color][/b]
[/list]
[list]
[*][b][color=green]tiles.xml[/color][/b]
[/list]
[list]
[*][b][color=green]classic.jsp[/color][/b]
[/list]
[list]
[*][b][color=green]index.jsp[/color][/b]
[/list]
[list]
[*][b][color=green]banner.jsp[/color][/b]
[/list]
[list]
[*][b][color=green]common_menu.jsp[/color][/b]
[/list]
[list]
[*][b][color=green]home_body.jsp[/color][/b]
[/list]
[list]
[*][b][color=green]credits.jsp[/color][/b]
[/list]
[*][b][color=green]Package Explorer[/color][/b]
[/list]
[img]http://dl2.iteye.com/upload/attachment/0100/6418/dbdfe4ca-7081-3ff0-b110-ce55cc8b1e04.png[/img]
[list]
[*][b][color=green]Result[/color][/b]
[/list]
[img]http://dl2.iteye.com/upload/attachment/0100/6420/53a1b76a-90f7-3424-a321-a2622b112c42.png[/img]
[list]
[*][b][color=green]pom.xml[/color][/b]
[/list]
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.hotfey</groupId>
<artifactId>TilesDemo</artifactId>
<packaging>war</packaging>
<version>0.0.1-SNAPSHOT</version>
<name>TilesDemo Maven Webapp</name>
<url>http://maven.apache.org</url>
<dependencies>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<version>3.8.1</version>
<scope>test</scope>
</dependency>
<dependency>
<groupId>org.apache.tiles</groupId>
<artifactId>tiles-extras</artifactId>
<version>3.0.4</version>
</dependency>
</dependencies>
<build>
<finalName>TilesDemo</finalName>
</build>
</project>
[list]
[*][b][color=green]web.xml[/color][/b]
[/list]
<!DOCTYPE web-app PUBLIC
"-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
"http://java.sun.com/dtd/web-app_2_3.dtd" >
<web-app>
<display-name>Archetype Created Web Application</display-name>
<listener>
<listener-class>org.apache.tiles.extras.complete.CompleteAutoloadTilesListener</listener-class>
</listener>
<servlet>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<servlet-class>org.apache.tiles.web.util.TilesDispatchServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>Tiles Dispatch Servlet</servlet-name>
<url-pattern>*.tiles</url-pattern>
</servlet-mapping>
</web-app>
[list]
[*][b][color=green]tiles.xml[/color][/b]
[/list]
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE tiles-definitions PUBLIC
"-//Apache Software Foundation//DTD Tiles Configuration 3.0//EN"
"http://tiles.apache.org/dtds/tiles-config_3_0.dtd">
<tiles-definitions>
<definition name="myapp.homepage" template="/layouts/classic.jsp">
<put-attribute name="title" value="Tiles tutorial homepage" />
<put-attribute name="header" value="/tiles/banner.jsp" />
<put-attribute name="menu" value="/tiles/common_menu.jsp" />
<put-attribute name="body" value="/tiles/home_body.jsp" />
<put-attribute name="footer" value="/tiles/credits.jsp" />
</definition>
</tiles-definitions>
[list]
[*][b][color=green]classic.jsp[/color][/b]
[/list]
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%>
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<%
String path = request.getContextPath();
String basePath = request.getScheme() + "://"
+ request.getServerName() + ":" + request.getServerPort()
+ path + "/";
%>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title><tiles:getAsString name="title" /></title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
body {
background-color: aqua;
}
</style>
</head>
<body>
<table>
<tr>
<td colspan="2"><tiles:insertAttribute name="header" /></td>
</tr>
<tr>
<td><tiles:insertAttribute name="menu" /></td>
<td><tiles:insertAttribute name="body" /></td>
</tr>
<tr>
<td colspan="2"><tiles:insertAttribute name="footer" /></td>
</tr>
</table>
</body>
</html>
[list]
[*][b][color=green]index.jsp[/color][/b]
[/list]
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles" %>
<tiles:insertDefinition name="myapp.homepage" />
[list]
[*][b][color=green]banner.jsp[/color][/b]
[/list]
This is header JSP page.
[list]
[*][b][color=green]common_menu.jsp[/color][/b]
[/list]
This is menu JSP page.
[list]
[*][b][color=green]home_body.jsp[/color][/b]
[/list]
This is body JSP page.
[list]
[*][b][color=green]credits.jsp[/color][/b]
[/list]
This is footer JSP page.