tiles框架的definition讲解
<?xml version="1.0" encoding="UTF-8"?> <!DOCTYPE tiles-definitions PUBLIC "-//Apache Software Foundation//DTD Tiles Configuration 1.1//EN" "http://jakarta.apache.org/struts/dtds/tiles-config_1_1.dtd"> <tiles-definitions> <!--classicLayout--> <definition name="layout.base" path="/layouts/classicLayout.jsp"> <put name="title" value="++welcome" /> <put name="header" value="/template/header.jsp" /> <put name="menu" value="/template/menu.jsp" /> <put name="footer" value="/template/footer.jsp" /> <put name="body" value="/template/body.jsp" /> </definition> <!-- 后台管理 --> <definition name="layout.backmanager" path="/layouts/classicLayout.jsp"> <put name="title" value="Back Manager" /> <put name="header" value="/template/back_header.jsp" /> <put name="menu" value="/back/menu.jsp" /> <put name="body" value="/back/main.jsp" /> <put name="footer" value="/template/footer.jsp" /> </definition> <!-- 前台首页 --> <definition name="front.main" extends="layout.base"> </definition> <!-- 后台管理-首页 --> <definition name="back.main" extends="layout.backmanager"> </definition> <!-- 后台管理-新增用户 --> <definition name="back.addUser" extends="layout.backmanager"> <put name="title" value="Add User" /> <put name="body" value="/back/addUser.jsp" /> </definition> </tiles-definitions>
上面转自http://blog.csdn.net/qjyong/article/details/1721253
back.addUser继承了layout.backmanager
标题将被替换成Add User
body将被替换成addUser.jsp
<definition name="base-definition" path="/layout.jsp"> <put name="sidebar" value="sidebar.jsp"/> <put name="header" value="header.jsp"/> <put name="content" value=""/> <put name="footer" value="footer.jsp"/> </definition> <definition name="index-definition" extends="base-definition"> <put name="content" value="indexContent.jsp"/> </definition>
这样一来,每次增加一个新的类似indexContent的页面时,只需要配置一个新的继承自base-definition的definition就OK了
自信与努力 用心坚持