Tiles傻瓜式入门―hajavaor―

来源:互联网 发布:mac book pro 壁纸 编辑:程序博客网 时间:2024/05/16 15:46
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
Tiles傻瓜式入门hajavaor―//===========================    Author:hajavaor    Email:hajavaor@eyou.com    QQ:19843788//===========================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的概念,而具体如何使用,请看相关文档。
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 728x15, 创建于 08-4-23MSDN */google_ad_slot = "3624277373";google_ad_width = 728;google_ad_height = 15;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>
<script type="text/javascript"><!--google_ad_client = "pub-2947489232296736";/* 160x600, 创建于 08-4-23MSDN */google_ad_slot = "4367022601";google_ad_width = 160;google_ad_height = 600;//--></script><script type="text/javascript"src="http://pagead2.googlesyndication.com/pagead/show_ads.js"></script>