sitemesh3 网页输出装饰器
来源:互联网 发布:linux dns配置 redhat 编辑:程序博客网 时间:2024/06/16 15:20
1.从官网下载一个jar包 sitemesh-3.0.1.jar
2.在web项目里的web.xml 添加过滤器
<filter> <filter-name>sitemesh</filter-name> <filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class> </filter> <filter-mapping> <filter-name>sitemesh</filter-name> <url-pattern>/*</url-pattern> </filter-mapping>3.新建sitemesh3.xml ,名字必须是sitemesh3
<?xml version="1.0" encoding="UTF-8"?><sitemesh> <!-- 指明满足“/*”的页面,将被“/WEB-INF/views/decorators/decorator.html”所装饰 --> <mapping path="/*" decorator="/decorator.html" /> <!-- 指明满足“/exclude.jsp*”的页面,将被排除,不被装饰 --> <mapping path="/exclude.jsp*" exclue="true" /></sitemesh>4.设置decorator.html
<!DOCTYPE html><html> <head> <title>SiteMesh example: <sitemesh:write property='title'/></title> <style type='text/css'> /* Some CSS */ body { font-family: arial, sans-serif; background-color: #ffffcc; } h1, h2, h3, h4 { text-align: center; background-color: #ccffcc; border-top: 1px solid #66ff66; } .mainBody { padding: 10px; border: 1px solid #555555; } .disclaimer { text-align: center; border-top: 1px solid #cccccc; margin-top: 40px; color: #666666; font-size: smaller; } </style> <sitemesh:write property='head'/> </head> <body> <h1 class='title'>this is a title<sitemesh:write property='title'/></h1> <div class='mainBody'> this BODY<sitemesh:write property='body'/>fff<sitemesh:write property='body'/> </div> <div class='disclaimer'>Site disclaimer. This is an example.</div> </body></html>
<sitemesh:write property='xxxx'/>标签就是原网页的内容(粗粒度的),可以多次加载
5.然后运行,打开要被渲染的网页 就行了。 原理:被渲染的网页 在输出前会因为上面的配置,其实会加载decorator.html网页,并输出。
0 0
- sitemesh3 网页输出装饰器
- sitemesh3装饰器无法装饰“.action”请求的问题
- 使用sitemesh3装饰页面
- sitemesh3配置
- SiteMesh3配置
- sitemesh3 配置文件
- sitemesh3配置
- SiteMesh3配置
- sitemesh3配置
- SiteMesh3入门教程
- 运用decorate装饰器模拟网页登陆(含代码)
- SiteMesh3使用详解
- sitemesh3.0 自定义标签
- sitemesh3.0配置
- sitemesh3-springMVC配置
- sitemesh3配置问题
- SiteMesh3使用。注解方式
- SiteMesh3简介及使用
- php防sql注入
- CodeForces 691C Exponential notation(模拟)
- DBA learning---2
- iOS 设置UITextField的输入限制
- pool(六)——JedisPool
- sitemesh3 网页输出装饰器
- Servlet异常处理
- ROS中用摇杆控制电机(四个电机转动)
- 设计模式学习之路 - 序言 - 记录自己的成长历程
- 最好的规划就是天衣无缝,让人无机可乘
- 如何选择真静态和伪静态?
- 深入Final关键字
- Jquery 选择 select 、radio 的几种方式
- 弹性图片