IT/프로젝트

SiteMesh 프레임워크

Lyk 2023. 10. 28. 23:07
728x90
반응형

: SiteMesh 프레임워크로 include 대신 공통레이아웃을 지정할 수 있다.

1. pom.xml 에 의존성 추가
<dependency>
<groupId>opensymphony</groupId>
<artifactId>sitemesh</artifactId>
<version>2.4.2</version>

2. web.xml 에 SiteMesh가 제공하는 PageFilter 를 설정.
<filter>
<filter-name>sitemesh</filter-name>
<filter-class>com.opensymphony.module.sitemesh.filter.PageFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>sitemesh</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

3. sitemesh.xml 설정. 이 파일은 반드시 WEB-INF/sitemesh.xml 에 위치해야한다.
=> 기본적은 sitemesh의 설정 및 사용할 decorators.xml 파일을 호출하는 역할
<excludes file="${decorators-file}"/> => decorators.xml 에 정의된 excludes 태그를 사용한다는 선언.

4. decorators.xml
정의된 decorator 패턴을 지정하는 역할
4-1. excludes => url 이 해당패턴일 땐 decorator 을 사용하지 않음
<excludes>
<pattern>~~~</pattern>
</excludes>
4-2. decorator => url 이 해당패턴일 땐 지정된 page 의 레이아웃 형태를 사용한다.
<decorator page="">
<pattern>~~~</pattern>
</decorator>
4-3. jsp 에서 사용하는 방법
<%@ taglib uri="http://www.opensymphony.com/sitemesh/decorator" prefix="decorator" %> => decorator 사용 선언
<decorator:title><decorator:title /> => 컨텐츠 페이지에서 title 부분을 가져온다.
<decorator:head><decorator:head /> => 컨텐츠 페이지에서 head 부분을 가져온다.
<decorator:body><decorator:body /> => 컨텐츠 페이지에서 body 부분을 가져온다.

 

 

참고 블로그 : http://cofs.tistory.com/273

728x90
반응형