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;深度优先,匹配最精确的,利用它来修饰 --><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,应该放置为第一个过滤器的位置,防止意外 --><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标签库 -->
<%@ 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!!!当前功能:<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],并且引入当前页面 --><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>
结果现象:


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>

结果现象:

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>

结果现象:

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>

结果现象:

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>

结果现象:

sitemesh初步相关推荐

  1. TensorRT 7.2.1开发初步

    TensorRT 7.2.1开发初步 TensorRT 7.2.1开发人员指南演示了如何使用C ++和Python API来实现最常见的深度学习层.它显示了如何采用深度学习框架构建现有模型,并使用该模 ...

  2. SOC,System on-a-Chip技术初步

    SOC,System on-a-Chip技术初步 S O C(拼作S-O-C)是一种集成电路,它包含了电子系统在单个芯片上所需的所有电路和组件.它可以与传统的计算机系统形成对比,后者由许多不同的组件组 ...

  3. 《OpenCV3编程入门》学习笔记3 HighGUI图形用户界面初步

    第3章 HighGUI图形用户界面初步 3.1 图像的载入.显示和输出到文件 1.OpenCV命名空间2种访问方法 (1)代码开头加:usingnamespace cv; (2)每个类或函数前加:cv ...

  4. 初步判断内存泄漏方法

    有时候,内存泄漏不明显,或者怀疑系统有内存泄漏,我们可以通过下面介绍的方法初步确认系统是否存在内存泄漏. 首先在Java命令行中增加-verbose:gc参数, 然后重新启动java进程. 当系统运行 ...

  5. android蓝牙4.0(BLE)开发之ibeacon初步

    一个april beacon里携带的信息如下 ? 1 <code class=" hljs ">0201061AFF4C0002159069BDB88C11416BAC ...

  6. 游戏AI之初步介绍(0)

    目录 游戏AI是什么? 游戏AI和理论AI 智能的假象 (更新)游戏AI和机器学习 介绍一些游戏AI 4X游戏AI <求生之路>系列 角色扮演/沙盒游戏中的NPC 游戏AI 需要学些什么? ...

  7. 【转】ibatis的简介与初步搭建应用

    [转]ibatis的简介与初步搭建应用 一.ibatis的简介 ibatis是什么东西就不介绍了,自己去找谷老师. 这里讲下自己的使用体会.之前自己学过Hibernate,是看尚学堂的视频教学的,看完 ...

  8. 初步了解:使用JavaScript进行表达式(De Do Do Do,De Da Da Da)

    by Donavon West 由Donavon West 初步了解:使用JavaScript进行表达式(De Do Do Do,De Da Da Da) (A first look: do expr ...

  9. 存储过程和存储函数初步

    2019独角兽企业重金招聘Python工程师标准>>> 存储过程和函数初步 简单的来说,存储过程就是一条或者多条 SQL 语句的集合,可视为批处理文件,但是其作用不仅限于批处理. # ...

  10. SiteMesh介绍

    1. SiteMesh简介 SiteMesh是由一个基于Web页面布局.装饰以及与现存Web应用整合的框架.它能帮助我们在由大量页面构成的项目中创建一致的页面布局和外观,如一致的导航条,一致的bann ...

最新文章

  1. ubuntu mysql master slave_Ubuntu下MySQL5.5 配置主从(Master Slave)同步
  2. python 开发框架_python的web开发框架有哪些
  3. 【渝粤教育】国家开放大学2019年春季 242机械制图 参考试题
  4. 【Windows C++笔记】winbase.h
  5. oracle中某字段显示long,ORACLE的ALL_VIEWS数据字典text字段long类型问题
  6. [争什么! 掺在一起做撒尿牛丸啊! 笨蛋]ASP.NET Core 2.0 + EF6 + Linux +MySql混搭
  7. python learning2.py
  8. Sublime Text 模板插件SublimeTmpl
  9. linux下二进制包、源代码包、rpm包
  10. Office 2007中的config.xml个性定制说明
  11. 人机协作机器人发展趋势_人工智能非万能!智能安防机器人下一站:人机协作...
  12. C语言struct 函数,C语言结构体史上最详细的讲解
  13. 记录一下Material Dialogs的使用
  14. android通知栏的点击事件,android自定义通知栏以及点击事件
  15. Java-底层建筑-JVM-第3篇-StringTable
  16. 上市公司融资需要哪些条件
  17. 陕西省2021年高考成绩位次查询,陕西高考排名查询方法,2021年陕西高考成绩位次全省排名查询...
  18. mac远程登录虚拟机
  19. python——class.__dict__
  20. java 实现重定义数组类似于VB的ReDim

热门文章

  1. potplayer如何设置以一帧一帧的逐帧播放播放?
  2. DDC 显示器数据通道
  3. DataFormatString格式化
  4. firework.js
  5. OpenCore引导配置说明第十三版-基于OpenCore-0.6.6正式版
  6. 床长人工智能教程 - 前言
  7. adodb 连接mysql_PHP程序中使用adodb连接不同数据库的代码实例
  8. 安居客头部买房部分书写
  9. java 限制文件大小_java上传文件大小限制
  10. 频谱仪的更改ip_通过局域网(LAN)读取频谱分析仪图像的方法