Click here to Skip to main content
15,887,596 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
My files are,

baselayout.jsp

XML
<%@ taglib uri="http://tiles.apache.org/tags-tiles" prefix="tiles"%>
<!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><tiles:insertAttribute name="title" ignore="true" /></title>
</head>
<body>
<table border="1" cellpadding="2" cellspacing="2" align="center">
    <tr>
        <td height="30" colspan="2"><tiles:insertAttribute name="header" />
        </td>
    </tr>
    <tr>
        <td height="250"><tiles:insertAttribute name="menu" /></td>
        <td width="350"><tiles:insertAttribute name="body" /></td>
    </tr>
    <tr>
        <td height="30" colspan="2"><tiles:insertAttribute name="footer" />
        </td>
    </tr>
</table>
</body>
</html>


Menu.jsp
XML
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<s:a href="customer-form">Customer</s:a>


body.jsp
This is a body


Header.jsp

XML
<%@ page contentType="text/html; charset=UTF-8"%>
<%@ taglib prefix="s" uri="/struts-tags"%>
<h2>Struts2 Example - ViralPatel.net</h2>


struct.xml in src


<!DOCTYPE struts PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 2.0//EN"
"http://struts.apache.org/dtds/struts-2.0.dtd">
<struts>
<constant name="struts.enable.DynamicMethodInvocation">
value="false" />
<constant name="struts.devMode" value="false">
<constant name="struts.custom.i18n.resources">
value="ApplicationResources" />
<package name="default" extends="struts-default" namespace="/">
<result-types>
<result-type name="tiles">
class="org.apache.struts2.views.tiles.TilesResult" />

<!-- <action name="login">
class="net.viralpatel.struts2.LoginAction">
<result name="success" type="tiles">/welcome.tiles
<result name="error">Login.jsp

<action name="customer">
class="net.viralpatel.struts2.CustomerAction">
<result name="success" type="tiles">/customer.success.tiles
<result name="input" type="tiles">/customer.tiles
-->
<action name="customer-form">
<result name="success" type="tiles">/customer.tiles




tile.xml

XML
<?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="baseLayout" template="/BaseLayout.jsp">
        <put-attribute name="title" value="" />
        <put-attribute name="header" value="/Header.jsp" />
        <put-attribute name="menu" value="/Menu.jsp" />
        <put-attribute name="body" value="/body.jsp" />
        <put-attribute name="footer" value="/Footer.jsp" />
    </definition>
</tiles-definitions>
Posted
Updated 27-Aug-14 19:01pm
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900