到 Google 资讯主页   
EasyJF首页   资料   源码   软件    论坛   网站    
   使用帮助    
    该信息为本站MyRSS系统缓存内容,部分图片及附件有可能无法正常使用.easyjf.comwww.javaresearch.org无关,不对该信息负责.通过http://www.javaresearch.org/article/77548.htm访问该信息的原始内容.
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   
struts的tiles框架应用的一些体会
作者:jacky_zz 来源:www.javaresearch.org  发布时间:2007-12-11 11:00:45.647


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"/>



 
相关文章
 
页面功能  【加入收藏】 【推荐给朋友】 【字体:  】 【关闭】   


EasyJF.com 2006 隐私政策 使用EasyJF前必读