tiles
来源:互联网 发布:下载藏文软件 编辑:程序博客网 时间:2024/04/29 22:43
http://struts.apache.org/userGuide/dev_tiles.html上面是这么说得:Tiles builds on the "include" feature provided by the JavaServer Pages specification to provide a full-featured, robust framework for assembling presentation pages from component parts.大意是说tiles是从jsp的“include”发展过来的以提供更加全面特性的,健壮的集成组件框架给页面。说白了,还不是再利用一下吗,搞了这么多名目繁多的东西,让我又要记住一大堆东西,这时才觉得软件业还是有个领袖好啊,大家才不至于迷失方向。
闲话不多说,我来说说tiles,作用刚才说过了,主要是要想利用它要做到:
1。在web-inf/struts-config.xml中加入如下的配置
<taglib>
<taglib-uri>struts-tiles.tld</taglib-uri>
<taglib-location>/WEB-INF/struts-tiles.tld</taglib-location>
</taglib>
当然你必须的确保这个struts-tiles.tld放在了这个目录其中。如果没有去jarkarta上下载吧,现在是struts1.2.7。它里面包含了。
2。给tiles加个定义文件
如果想集成定义呢,还得在WEB-INF/目录下create一个tiles-def.xml然后在struts-config.xml中加入如下语句,以让actionServlet init的时候能够把tiles模板配置信息记录下来。
<plug-in className="org.apache.struts.tiles.TilesPlugin" >
<set-property property="definitions-config" value="/WEB-INF/tiles-defs.xml" />
<set-property property="definitions-parser-validate" value="true" />
</plug-in>
tiles-def.xml可以象下面这样
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!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="/layout.jsp">
<put name="sidebar" value="sidebar.jsp"/>
<put name="header" value="header.jsp"/>
<put name="content" value="indexContent.jsp"/>
<put name="footer" value="footer.jsp"/>
</definition>
<definition name="product-definition" path="/layout.jsp">
<put name="sidebar" value="sidebar.jsp"/>
<put name="header" value="header.jsp"/>
<put name="content" value="productContent.jsp"/>
<put name="footer" value="footer.jsp"/>
</definition>
</tiles-definitions>
当然也可以把definition 写在任何一个jsp页面啦.
<%@ taglib uri="/WEB-INF/tiles.tld" prefix="tiles" %>
<tiles:definition id="definitionName" page="/layouts/myLayout.jsp" >
<tiles:put name="title" value="Page Title" />
<tiles:put name="header" value="/tiles/header.jsp" />
<tiles:put name="footer" value="/tiles/footer.jsp" />
<tiles:put name="menu" value="/tiles/menu.jsp" />
<tiles:put name="body" value="/tiles/helloBody.jsp" />
</tiles:definition>
它会被存为一个scope,而且还可以用scope=session|page|request设定这个definition的使用范围.
3.下面是tiles将要用到的tag和作用的描述。
Tag Name Description insert Insert a tiles/component/template. definition Create a tile /component / template definition bean. put Put an attribute into tile/component/template context. putList Declare a list that will be pass as attribute to tile. add Add an element to the surrounding list. Equivalent to 'put', but for list element. get Gets the content from request scope that was put there by a put tag. getAsString Render the value of the specified tile/component/template attribute to the current JspWriter useAttribute Use attribute value inside page. importAttribute Import Tile's attribute in specified context. initComponentDefinitions Initialize Tile/Component definitions factory.insert就是include了。最常用的结构就是
Definitions在定义中用,象上面的例子中一样。有几个属性id extends scope page不说也明白吧。
put挺常用的,属性有name,value,type=string|page|templage|definition,direct ,content
还有个useAttribute也挺常用,都比较简单。
4.tiles还使用了commons-logging包以输出不同的信息和调试声明,要想这样,首先在web-inf/classes下面自己动手建两个文件:
commons-logging.properties
org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
simplelog.properties
# Logging detail level,
# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
org.apache.commons.logging.simplelog.defaultlog=traceDefinitions在定义中用,象上面的例子中一样。有几个属性id extends scope page不说也明白吧。
put挺常用的,属性有name,value,type=string|page|templage|definition,direct ,content
还有个useAttribute也挺常用,都比较简单。
4.tiles还使用了commons-logging包以输出不同的信息和调试声明,要想这样,首先在web-inf/classes下面自己动手建两个文件:
commons-logging.properties
org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
simplelog.properties
# Logging detail level,
# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
org.apache.commons.logging.simplelog.defaultlog=traceDefinitions在定义中用,象上面的例子中一样。有几个属性id extends scope page不说也明白吧。
put挺常用的,属性有name,value,type=string|page|templage|definition,direct ,content
还有个useAttribute也挺常用,都比较简单。
4.tiles还使用了commons-logging包以输出不同的信息和调试声明,要想这样,首先在web-inf/classes下面自己动手建两个文件:
commons-logging.properties
org.apache.commons.logging.Log=org.apache.commons.logging.impl.SimpleLog
simplelog.properties
# Logging detail level,
# Must be one of ("trace", "debug", "info", "warn", "error", or "fatal").
org.apache.commons.logging.simplelog.defaultlog=trace
- tiles
- tiles
- tiles
- Tiles
- Tiles框架
- struts tiles
- tiles用法
- Tiles配置
- Apache Tiles
- Tiles框架
- Tiles & SiteMesh
- spring tiles
- Tiles简介
- Tiles框架
- tiles准备
- tiles框架
- tiles 使用
- struts tiles
- 初学的我需要您的帮助!!!
- JSP环境配置
- 编程人员发布新工具 好莱坞打击盗版更困难
- G_server进程
- SSL VPN渐得人心
- tiles
- Google 搜索技巧
- 迷茫中发动机:>
- 苹果宣布转向英特尔 乔布斯阐述“倒戈”原因
- 高层销售怎样做
- 高考纪念日
- 网络恐怖袭击真实存在吗
- DNN安装模板(DotNetNuke.install)
- Opera的Acid2向微软发出挑战