日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

sitemesh初步

發(fā)布時間:2023/12/20 编程问答 34 豆豆
生活随笔 收集整理的這篇文章主要介紹了 sitemesh初步 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

sitemesh小項目

1.工程目錄

2.需要的lib:sitemesh-2.4.2.jar
http://wiki.sitemesh.org/wiki/display/sitemesh/Download
3.配置
decorators.xml[sitemesh的配置文件]

<?xml version="1.0" encoding="ISO-8859-1"?><!-- 在defaultdir目錄查找decorator文件 --> <decorators defaultdir="/WEB-INF/decorator"><!-- Any urls that are excluded will never be decorated by Sitemesh --><excludes><pattern>/exclude.jsp</pattern><pattern>/exclude/*</pattern></excludes><!-- 利用basic.jsp修飾所有的頁面 --><decorator name="basic" page="basic.jsp"><pattern>/*</pattern></decorator><!-- 僅僅只使用main.jsp修飾頁面/02.jsp;深度優(yōu)先,匹配最精確的,利用它來修飾 --><decorator name="main" page="main.jsp"><pattern>/02.jsp</pattern></decorator><!-- panel裝飾器會直接在01.jsp引入 --><decorator name="panel" page="panel.jsp"></decorator> </decorators>

web.xml[web工程的配置文件]:

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0"><display-name>sitemesh01</display-name><welcome-file-list><welcome-file>index.html</welcome-file><welcome-file>index.htm</welcome-file><welcome-file>index.jsp</welcome-file><welcome-file>default.html</welcome-file><welcome-file>default.htm</welcome-file><welcome-file>default.jsp</welcome-file></welcome-file-list><!-- 添加sitemesh的Filter,應(yīng)該放置為第一個過濾器的位置,防止意外 --><filter><filter-name>sitemesh</filter-name><filter-class>com.opensymphony.sitemesh.webapp.SiteMeshFilter</filter-class></filter><filter-mapping><filter-name>sitemesh</filter-name><url-pattern>/*</url-pattern></filter-mapping></web-app>

4.sitemesh的裝飾器
decorator/basic.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!-- 引入sitemesh標(biāo)簽庫 --> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <!-- decorator:title 用于引入修飾頁面的title --> <title><decorator:title /></title> <!-- decorator:head 用于引入修飾頁面的head信息 --> <decorator:head /> </head> <body><h2 align="center">weclome!!!當(dāng)前功能:<decorator:title /> </h2><hr /><!-- decorator:body 引入修飾頁面的body部分信息 --><decorator:body /><div align="center">CopyRight@2019-2099</div> </body> </html>

decorator/main.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title><decorator:title /></title> </head> <body><h2 align="center">weclome!! 其他模塊:<decorator:title /> </h2><hr /><decorator:body /><div align="center">CopyRight@2021-2051</div> </body> </html>

decorator/panel.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> <style type="text/css">#pheader{width: 300px;border: 1px solid #f00;}#pcontent{padding: 10px 0px;background: #59b;color: #fff;border-bottom: 1px solid #000;border: 1px solid #f00;} </style> <div><div id="pheader"><decorator:title default="default title" /></div><div id="pcontent"><decorator:body /></div><hr/> </div>

5.Viewer層,顯示界面
WebContent/01.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>01jsp</title> <style type="text/css">table{color: #3A9CD3;} </style> </head> <body><!-- 使用裝飾器name[panel]來裝飾page[/exclude/02.jsp],并且引入當(dāng)前頁面 --><page:applyDecorator name="panel" page="/exclude/02.jsp"></page:applyDecorator><page:applyDecorator name="panel" page="/exclude/01.jsp"></page:applyDecorator><page:applyDecorator name="panel" page="/04.jsp"></page:applyDecorator><table width="900" border="1" align="center" cellspacing="0"><thead><tr><td>用戶ID</td><td>姓名</td></tr></thead></table> </body> </html> 結(jié)果現(xiàn)象:


WebContent/02.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>02jsp</title> </head> <body><table width="900" border="1" align="center"><thead><tr><td>用戶ID</td><td>姓名</td></tr></thead></table> </body> </html>

結(jié)果現(xiàn)象:

WebContent/04.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <title>04jsp</title> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> </head> <body><div>這個是個普通的panel</div> </body> </html>

結(jié)果現(xiàn)象:

WebContent/exclude/01.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ex-01jsp</title> </head> <body><table width="900" border="1" align="center"><thead><tr><td>用戶ID11111111</td><td>姓名</td></tr></thead></table> </body> </html>

結(jié)果現(xiàn)象:

WebContent/exclude/02.jsp:

<%@ page language="java" contentType="text/html; charset=UTF-8"pageEncoding="UTF-8"%> <%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>ex-02jsp</title> </head> <body><table border="1" align="center" cellspacing="0"><thead><tr><td>用戶ID222222222222</td><td>姓名</td></tr></thead></table> </body> </html>

結(jié)果現(xiàn)象:

總結(jié)

以上是生活随笔為你收集整理的sitemesh初步的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。