You are viewing an old version of this page. View the current version.

Compare with Current View Page History

Version 1 Next »

Step 1. Update your web application configuration (web.xml)

<context-param>
                <description>Tiles configuration file</description>
                <param-name>
                        org.apache.tiles.impl.BasicTilesContainer.DEFINITIONS_CONFIG
                </param-name>
                <param-value>/WEB-INF/classes/tiles.xml, /WEB-INF/tiles.xml</param-value>
        </context-param>
        <servlet>
                <servlet-name>tiles</servlet-name>
                <servlet-class>
                        org.apache.tiles.web.startup.TilesServlet
                </servlet-class>
                <load-on-startup>2</load-on-startup>
        </servlet>
        <servlet>
                <servlet-name>tiles_dispatch</servlet-name>
                <servlet-class>
                        org.apache.tiles.web.util.TilesDispatchServlet
                </servlet-class>
        </servlet>
        <servlet-mapping>
                <servlet-name>tiles_dispatch</servlet-name>
                <url-pattern>*.tiles</url-pattern>
        </servlet-mapping>

Step 2. Add tiles.xml in your web application archive (WAR)

Place Tiles configuration to /WEB-INF or /WEB-INF/classes.

tiles.xml example:

<?xml version="1.0" encoding="UTF-8" ?><!DOCTYPE tiles-definitions PUBLIC
       "-//Apache Software Foundation//DTD Tiles Configuration 2.0//EN"
       "http://tiles.apache.org/dtds/tiles-config_2_0.dtd">
<tiles-definitions>
        <definition name="test" template="index.jsp">
        </definition>
</tiles-definitions>

Step 3. Place your "index.jsp" in root of WAR archive.

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Test page</title>
</head>
<body>
    <h3>Success...</h3>
</body>
</html>

Step 4. Copy Tiles libraries.

Copy Tiles libraries to WEB-INF/lib (tiles-.jar and common-.jar).

Step 5. Create and deploy your WAR archive.

Run web application in web container (like Tomcat) and navigate url http://localhost:8080/mywebapp/test.tiles

Step 6. Create your custom tiles definitions.

  • No labels