Tiles傻瓜式入门

0、适用读者:了解Tag lib,使用Struts(当然了,Tiles属于Struts嘛。)
1、有一个文件,名为test.jsp。内容如下:
    <html><body>This is the header.</body></html>
    <
html><body>This is the body. </body></html>
    <
html><body>This is the footer. </body></html>
2、拆此文件为三个文件,分别为:       
    test_header.jsp
        <
html><body>This is the header.</body></html>       
   
    test_body.jsp
        <
html><body>This is the body.</body></html>       
   
    test_footer.jsp
        <
html><body>This is the footer.</body></html>
3、修改test.jsp文件,使用tiles标签。这便是我的第一个tiles例子了。
    <tiles:insert
page="test_header.jsp"/>
    <tiles:insert
page="test_body.jsp"/>
    <tiles:insert
page="test_footer.jsp"/>       
   
    由原来的一个文件变成了四个文件。继续看。
4、将上面的文件再换成下面两个文件:       
    test_template.jsp,这是一个模板文件。
   
    <html:html>       
        <
head><title></title></head>              
        <
body>                     
            <tiles:insert
attribute="header"/>                     
            <tiles:insert
attribute="body"/>                     
            <tiles:insert
attribute="footer"/>              
        <
/body>
    </html:html>  
   
    将test.jsp改成这样:
    <tiles:insert
page="/test_template.jsp" flush="true">
        <tiles:put
name="header" value="/test_header.jsp" />
        <tiles:put
name="body" value="/test_body.jsp" />
        <tiles:put
name="footer" value="/test_footer.jsp" />
    </tiles:insert>
5、再进一步修改,编辑一个tiles-defs.xml文件,内容为:
    <definition
name="MyTilesTest" path="/test_template.jsp">
        <put
name="header" value="/test_header.jsp" />
        <put
name="body"  value="/test_body.jsp" />
        <put
name="footer" value="/test_footer.jsp" />
    </definition>
   
    修改test.jsp文件内容为:
        <tiles:insert
definition name="MyTilesTest" />
       
    就变成一句代码了,很简洁吧。
    怎么样,你知道Tiles是怎么回事了吧,就算入门了,赶紧看Tiles的API吧。
    本文的目的只是让你建立Tiles的概念,而具体如何使用,请看相关文档。
 
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
红包 添加红包
表情包 插入表情
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值