=========================web.xml=============================
<filter>
<filter-name>sitemeshTest</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemeshTest</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
모든 url 패턴에 sitemesh를 적용하겠다는것
========================sitemesh.xml=======================================
<?xml version="1.0" encoding="UTF-8"?>
<sitemesh>
<property name="decorators-file" value="/WEB-INF/decorators.xml" />
<excludes file="${decorators-file}" />
<page-parsers>
<parser content-type="text/html" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
<parser content-type="text/html;charset=EUC-KR" class="com.opensymphony.module.sitemesh.parser.HTMLPageParser" />
</page-parsers>
<decorator-mappers>
<mapper class="com.opensymphony.module.sitemesh.mapper.ConfigDecoratorMapper">
<param name="config" value="${decorators-file}" />
</mapper>
</decorator-mappers>
</sitemesh>
"/WEB-INF/decorators.xml" 경로의 파일을 실행하겠다는 뜻
======================decorators.xml=============================================
<?xml version="1.0" encoding="UTF-8" ?>
<decorators defaultdir="/decorator">
<decorator name="main" page="/decorator/main_decorator.jsp">
<pattern>/main/*</pattern>
</decorator>
<decorator name="member" page="/decorator/member_decorator.jsp">
<pattern>/member/*</pattern>
</decorator>
<excludes>
<pattern>/main/exclude.jsp</pattern>
<pattern>/member/exclude.jsp</pattern>
</excludes>
</decorators>
이름에 맞게 실행 , exclude에 있는건 제외
=======================WebContent - decorator - hello_decorator.jsp===========================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<%@ taglib prefix="decorator" uri="http://www.opensymphony.com/sitemesh/decorator"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
<title><decorator:title /></title> ->데코레이터가 적용될 화면의 값이 여기에 적용된다
<style type="text/css">
.mainTable {
width: 500px;
height: 300px;
}
.mainTable td {
background-color: gray;
}
</style>
<decorator:head /> ->데코레이터가 적용될 화면의 값이 여기에 적용된다
</head>
<body>
<table class="mainTable">
<tr>
<td colspan="2" style="height: 50px;">
<jsp:include page="top.jsp" /></td>
</tr>
<tr>
<td><jsp:include page="menu.jsp" /></td>
<td><decorator:body /></td> ->데코레이터가 적용될 화면의 값이 여기에 적용된다
</tr>
</table>
</body>
</html>
자바 애노테이션 타겟지정,리텐션 지정 (0) | 2015.03.28 |
---|---|
자바 jsp 애노테이션 (0) | 2015.03.26 |
jsp toJSON 결과 화면 (0) | 2015.03.24 |
jsp 회원 리스트를 JSONObject , array로 받아오기 (0) | 2015.03.24 |
jsp toBean (0) | 2015.03.24 |