一基本包(個)
monsloggingjar
monsfileuploadjar
ognljar
strutscorejar
xworkjar
freemarkerjar
二整合tiles必須包(個)
strutstilespluginjar
tilesapijar
tilescorejar
tilesjspjar
monsdigesterjar
monscollectionsjar
monsbeanutilsjar
三把tilesjspjar包下的tilesjsptld 拷貝到WEBINF下WEBINF/tilesjsptld
四創建tilesxml 放在WEBINF下WEBINF/tilesxml 如下:
<?xml version= encoding=UTF?>
<!DOCTYPE tilesdefinitions PUBLIC //Apache Software Foundation//DTD Tiles Configuration //EN /dtds/tilesconfig__dtd>
<tilesdefinitions>
<definition name=xixihaha template=layoutjsp>
<putattribute name=header value=headjsp />
<putattribute name=sidebar value=sidebarjsp />
<putattribute name=contant value=contantjsp />
<putattribute name=footer value=footjsp />
</definition>
</tilesdefinitions>
五在webxml添加如下:
<contextparam>
<paramname>orgapachetilesCONTAINER_FACTORY</paramname>
<paramvalue>orgapachestrutstilesStrutsTilesContainerFactory</paramvalue>
</contextparam>
<contextparam>
<paramname>orgapachetilesimplBasicTilesContainerDEFINITIONS_CONFIG</paramname>
<paramvalue>/WEBINF/tilesxml</paramvalue>
</contextparam>
<listener>
<listenerclass>orgapachestrutstilesStrutsTilesListener</listenerclass>
</listener>
六修改strutsxml
<!DOCTYPE struts PUBLIC
//Apache Software Foundation//DTD Struts Configuration //EN
/dtds/strutsdtd>
<struts>
<package name=default extends=tilesdefault >
<action name=XXAction class=comXXAction>
<result name=success type=tiles >xixihaha </result>
</action>
</package>
</struts>
七創建layoutjsp注意存放路徑要和tilesxml一致
<%@ taglib uri=/WEBINF/tilesjsptld prefix=tiles%>
<table>
<tr><td><tiles:insertAttribute name=header></tiles:insertAttribute></td></tr>
<tr><td><tiles:insertAttribute name=sidebar></tiles:insertAttribute></td></tr>
<tr><td><tiles:insertAttribute name=contant></tiles:insertAttribute></td></tr>
<tr><td><tiles:insertAttribute name=footer></tiles:insertAttribute></td></tr>
</table>
八創建headjspsiderbarjspcontantjspfooterjsp
九測試創建indexjsp
<form action=XXActiondo method=post>
<input type=submit/>
</form>
From:http://tw.wingwit.com/Article/program/Java/ky/201311/28063.html