框架:struts的tiles框架应用的一些体会

上一篇 / 下一篇  2007-12-22 12:08:00 / 个人分类:技术摘录

 

1.在struts-config.xml中插入下文件:

< plug-in className="org.apache.struts.tiles.TilesPlugin">
   < set-property   property="definitions-config"   value="/WEB-INF/tiles-defs.xml"/>
    < set-property   property="moduleAware" value="false"/> 
  < /plug-in>
2.web.xml文件加入标签库的应用:
< jsp-config>
  < taglib>
     < taglib-uri>/WEB-INF/struts-tiles.tld< /taglib-uri>
     < taglib-location>/WEB-INF/struts-tiles.tld< /taglib-location>
  < /taglib>
  < /jsp-config> 
3.在页面上使用< %@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>引入tiles标签。
4.定义tiles-defs.xml文件:
< ?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>  
        < definition     name="index-definition"     path="/MyJsp2.jsp">                              
        < /definition>               
  < /tiles-definitions> 
5.编写页面框架:
< %@ page language="java" pageEncoding="GB2312"%>
< %@ taglib uri="/WEB-INF/struts-tiles.tld" prefix="tiles" %>


< !DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
< html>
  < head>
   
    < title>< tiles:getAsString name="title"/>< /title>

    < meta http-equiv="pragma" content="no-cache">
    < meta http-equiv="cache-control" content="no-cache">
    < meta http-equiv="expires" content="0">   
    < meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
    < meta http-equiv="description" content="This is my page">


  < /head>
 
  < body  text="#333333" bgcolor="#ffffff" leftmargin="2" topmargin="2"marginwidth="0" marginheight="0">
  < div align="center">
    < tiles:insert attribute="top" />
    < table border="0" width="100%" height="90%" cellspacing="0" cellpadding="0">
       < tr>
          < td width="15%" height="80%" valign="top" align="left" >
            < tiles:insert attribute="left" />
          < /td>        
          < td width="85%" align="center" height="50%" valign="top">
             < tiles:insert attribute="body"/>
          < /td>
          < /tr>
     < /table>
     < tiles:insert attribute="bottom"/>                        
  < /div>  
  < /body>
< /html>

6。在web.xml配置< welcome-file-list>为包含以下内容的jsp页面welcome.jsp:
< tiles:insert definition="baseinfo_template" flush="true"/>


TAG:

 

评分:0

我来说两句

显示全部

:loveliness: :handshake :victory: :funk: :time: :kiss: :call: :hug: :lol :'( :Q :L ;P :$ :P :o :@ :D :( :)

日历

« 2008-07-04  
  12345
6789101112
13141516171819
20212223242526
2728293031  

数据统计

  • 访问量: 3693
  • 日志数: 226
  • 建立时间: 2007-08-01
  • 更新时间: 2008-06-04

RSS订阅

Open Toolbar