• SiteMesh


    1.导入对SiteMesh.jar的依赖

    <dependency>
          <groupId>org.sitemesh</groupId>
          <artifactId>sitemesh</artifactId>
          <version>3.0.0</version>
    </dependency>

    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>
  • 相关阅读:
    Single Number 解答
    Minimum Size Subarray Sum 解答
    Valid Anagram 解答
    Count Primes 解答
    fullCalendar 日历显示每天数据调用方法实践
    jqGrid列的统计
    关于 asp.net Web Api 上传文件请求内容过大404错误记录
    My97DatePicker只显示月份
    js 宏微任务执行顺序
    git 等官网下载慢方法
  • 原文地址:https://www.cnblogs.com/itliucheng/p/4462263.html
Copyright © 2020-2023  润新知