<?xml version="1.0" encoding="utf-8"?>
xmlns:xsi=""
version="2.4">
sitemesh
com.opensymphony.module.sitemesh.filter.pagefilter
/*30
index.jsp
新增藍色高亮部分。
<?xml version="1.0" encoding="iso-8859-1"?>
/*安裝完畢。
例子1
/test1.jsp
<%@ taglib uri="" prefix="decorator" %>
this message is in /decorators/mydecorator1.jsp
<%@page contenttype="text/html"%>
<%@page pageencoding="utf-8"%>
this is test1
this is test1
this message is in /decorators/mydecorator1.jsp
例子2 (decorator:getproperty tag)
有時候,我們期望修改頁面中某個有固定標記的片段,例如我們的jsp中有乙個標記...,此時可以用如下方法實現:
/test2.jsp
<%@ taglib uri="" prefix="decorator" %>
this message is in /decorators/mydecorator2.jsp
<%@page contenttype="text/html"%>
<%@page pageencoding="utf-8"%>
this is test2
use tag
this is content1
this is content2
this is content4, it shouldn't be display
this is test2
use tag
this is content1
this is content2
this message is in /decorators/mydecorator2.jsp
/test3.jsp
<%@ taglib uri="" prefix="decorator" %>
<%@ taglib uri="" prefix="page" %>
this is content2
<%@ taglib uri="" prefix="decorator" %>
<%@ taglib uri="" prefix="page" %>
begin
end<%@page contenttype="text/html"%>
<%@page pageencoding="utf-8"%>
this is test3
注意:相對於例子2,這裡已經沒有了標籤。
this is test3
begin
this is content1
this is content2
end
這裡,我在mydecorator3.jsp中應用了mydecorator31.jsp的的decorator,並且將原來在test2.jsp中的 標籤複製到mydecorator3.jsp中,此時對於的標籤將會由mydecorator31.jsp了裝飾。
例子4 (page:param tag)
/test4.jsp
<%@ taglib uri="" prefix="decorator" %>
<%@ taglib uri="" prefix="page" %>
this is content2
this content1 has been replaced
<%@ taglib uri="" prefix="decorator" %>
<%@ taglib uri="" prefix="page" %>
begin
end<%@page contenttype="text/html"%>
<%@page pageencoding="utf-8"%>
this is test4
use tag
this is test4
use tag
begin
this content1 has been replaced
this is content2
end
這裡,我在mydecorator4.jsp中應用了mydecorator41.jsp的的decorator,並且新增了標籤,那麼此時頁面上將會用標籤中的內容替換原來在中的內容,因此頁面將不在「this is content1」而顯示「this content1 has been replaced」。
Sitemesh的配置與使用
1 web inf web.xml中加入filter定義與sitemesh的taglib定義 sitemeshfilter sitemeshfilter ps 需要放在struts下面 struts cleanup org.apache.struts2.dispatcher.actioncontex...
SiteMesh標籤使用說明
itemesh包括兩大標籤庫。decorator tags 被用於建立裝飾器頁面.page tags 被用於從原始內容頁面訪問裝飾器.做乙個簡單的介紹,了解一下各標籤的作用。1.插入原始頁面 被包裝頁面 的head標籤中的內容 不包括head標籤本身 2.插入原始頁面的標籤中的內容 不包括body標...
SiteMesh標籤使用說明
1.插入原始頁面的標籤中的內容。沒有屬性。2.插入原始頁面的標籤中的內容。注釋 裝飾jsp 可以在裝飾頁面body中使用如上語法來獲得被裝飾頁面的事件。3.插入被裝飾頁面的title標籤中的內容 default屬性 當沒有在被裝飾頁面找到title中有內容時此值被插入 4.插入原始頁面的proper...