sitemesh3.xml ===================================>html
配置文件放置在web-inf文件下,和web.xml同一個目錄java
<?xml version="1.0" encoding="UTF-8"?>web
<sitemesh>spring
<mapping path="/*" decorator="/WEB-INF/decorator.jsp" />app
<mapping path="/login" exclude="true" />jsp
<mapping path="/assets/*" exclude="true" />url
</sitemesh>spa
web.xml =============================================>
orm
<filter>xml
<filter-name>sitemeshFilter</filter-name>
<filter-class>org.sitemesh.config.ConfigurableSiteMeshFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemeshFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
decorator.jsp ======================================================>
<%@ page contentType="text/html;charset=UTF-8" language="java"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form"%>
<c:set var="ctx" value="${pageContext.request.contextPath}"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title><sitemesh:write property='title' /> - ltcms</title>
<sitemesh:write property='head' />
</head>
<body>
<header>header</header>
<hr />
demo.html的title將被填充到這兒:
<sitemesh:write property='title' /><br />
demo.html的body將被填充到這兒:
<sitemesh:write property='body' />
<hr />
<footer>footer</footer>
</body>
</html>