首页 > 其他 > 详细

SiteMesh

时间:2015-04-28 11:04:49      阅读:142      评论:0      收藏:0      [点我收藏+]

1.导入对SiteMesh.jar的依赖

2.web.xml中配置过滤器

<!-- SiteMesh -->
  <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>

3.WEB-INF中配置文件decorators.xml

<!-- /WEB-INF/content/theme表示存放模板(主题)的文件夹 -->
<?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/WEB-INF/content/theme">
            <!-- name随意起 page主题网页 -->
    <decorator name="simple-theme" page="layout.jsp">
        <!-- 指的是所有网页都进行装饰 -->
        <pattern>/*</pattern>
    </decorator>
    <excludes>
    <!-- 表示静态资源不受影响,img表示静态资源文件夹 -->
        <pattern>/img/*</pattern>
    </excludes>
    <excludes>
        <!-- 表示除了这个网页 -->
        <pattern>/admin/home.action</pattern>
    </excludes>

</decorators>

4.模板jsp的设置,需要导入标签

<%@ page language="java" pageEncoding="UTF-8"%>
<%@ taglib prefix="sitemesh-decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><sitemesh-decorator:title/></title>
<!-- 头部也要导入,比如css之类的 -->
<sitemesh-decorator:head/>
</head>
<body>
    <h1>head head</h1>
    <!-- 导入body的部分 -->
    <sitemesh-decorator:body/>
    <h1>这是底部</h1>
</body>
</html>

 

SiteMesh

原文:http://www.cnblogs.com/itliucheng/p/4462263.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!