sitemesh 配置手稿
来源:互联网 发布:知柏地黄丸儿童性早熟 编辑:程序博客网 时间:2024/06/09 23:57
使用的sitemesh包是sitemesh-2.4.jar现将这个包加入到WEB-INF/lib下也可以加入sitemesh-page.tld , sitemesh-decorator.tld两个文件(没有也没有影响)然后在web.xml下配置拦截器代码如下
<?xml version="1.0" encoding="UTF-8"?><web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"><display-name></display-name><welcome-file-list><welcome-file>index.jsp</welcome-file></welcome-file-list><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>
定义一个decorators.xml 放在WEB-INF根目录下,配置内容提供以下示例
<?xml version="1.0" encoding="UTF-8"?><decorators defaultdir="/decorators"> <decorator name="mai" page="mai.jsp"> <pattern>/mai.html</pattern> </decorator></decorators>
在WebRoot下面新建一个decorators文件夹 然后将装饰页面放在该目录如图所示
mai.jsp.内容如下所示
<%@ page language="java" import="java.util.*" pageEncoding="ISO-8859-1"%><%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %><%@ taglib uri="http://www.opensymphony.com/sitemesh/page" prefix="page" %><%String path = request.getContextPath();String basePath = request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/";%><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN"><html> <head> <base href="<%=basePath%>"> <title>My JSP 'mai.jsp' starting page</title> <meta http-equiv="pragma" content="no-cache"><meta http-equiv="cache-control" content="no-cache"><meta http-equiv="expires" content="0"> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"><meta http-equiv="description" content="This is my page"><!--<link rel="stylesheet" type="text/css" href="styles.css">--> <decorator:title></decorator:title> </head> <body> there is a decorator begin!<hr /><decorator:body></decorator:body>hello world <hr/> </body></html>
引入了两个标签库<decorator:title></decorator:title>用来将被装饰页面的title放在此处。<decorator:body></decorator:body>用来将被装饰页面的body内容放在此处。
在WebRoot根目录下面新建一个mai.html 示例内容如下
<!DOCTYPE html><html> <head> <title>maqiang</title> <meta http-equiv="keywords" content="keyword1,keyword2,keyword3"> <meta http-equiv="description" content="this is my page"> <meta http-equiv="content-type" content="text/html; charset=UTF-8"> <!--<link rel="stylesheet" type="text/css" href="./styles.css">--> </head> <body> This is my HTML page. <br> </body></html>这样就ok了
- sitemesh 配置手稿
- sitemesh配置
- struts2之整合sitemesh(sitemesh配置)
- sitemesh配置解析
- SiteMesh配置与使用
- Struts2 集成 sitemesh配置
- sitemesh、springmvc装饰配置
- sitemesh配置解析
- Sitemesh 3 配置
- Apache Tomcat 7.0.0 配置手稿
- ehcache web页面缓存配置手稿
- 【个人手稿】 IIS7远程发布配置
- SiteMesh在项目中的配置
- sitemesh原理与配置应用
- SSH配置(四)-sitemesh-velocity
- sitemesh原理与配置应用
- Sitemesh的配置与使用
- sitemesh
- Android组件的使用:Gallery
- C指针
- 你是否决绝平庸,你有勇气来学C/C++吗,有勇气来检验你是否经得起世界五百强的面试
- http://dl-ssl.google.com/android/eclipse/ 无法访问的解决办法
- JavaSE笔记05:面向对象的三大特征
- sitemesh 配置手稿
- iOS Assembly Tutorial: Understanding ARM
- 题目1438:最小公倍数
- 入门经典-p133-八数码问题
- QT5.1 FOR ANDROID 安装配置
- AlarmManager(手机闹钟服务)
- [leetcode刷题系列]N-Queens
- HDU 1028 母函数
- 函数指针的应用