티스토리 뷰
# sitemesh
웹 페이지의 레이아웃을 효울적으로 처리할 수 있도록 도와주는 프레임워크.
기본적으로 filter형식으로 동작하고 있음.
완전한 HTML 페이지를 생성한 뒤 Decorator라는 패턴을 사용하여
데코레이터HTML 페이지에 레이아웃을 입히는 방식.
즉, 원래) 요청 ->해당페이지->응답
sitemesh) 요청->해당페이지->decorator(sitemesh로 데코해줌)->응답
ex)
url 요청 = http://localhost:8282/sitemesh1/hello/a.jsp
**web.xml**
filter형식으로 선언되어있음
<filter-class>
com.opensymphony.module.sitemesh.filter.PageFilter
</filter-class>
안에 내부적으로 sitemesh.xml을 호출
**sitemesh.xml**
<property name="decorators-file"
value="/WEB-INF/decorators.xml" />
value에 우리가 쓸 템플릿의 정보 세팅된xml의 경로
**decorators.xml**
<decorators defaultdir="/decorator">
<decorator name="main" page="hello_decorator.jsp">
<pattern>/hello/*</pattern>
sitemesh를 적용할 곳의 패턴 지정
**hello_decorator.jsp**
1.<decorator:head />
-원본소스의 head 안의 내용을 여기에 넣음
2.<decorator:head />
-원본소스의 body 안의 내용을 여기에 넣음
3.<decorator:title />
-원본소스의 title 안의 내용을 여기에 넣음
4.<decorator:getProperty property=".." />
-원본페이지의 프로퍼티를 가져올 수 있다.(name까지)
5.<decorator:usePage id=".." />
-원본페이지의 객체에 접근 할 수 있다.
'VIEW > JSP&SERVLET' 카테고리의 다른 글
[JSP] 파일 업로드,답변형 게시판 (0) | 2017.12.01 |
---|---|
[JSP] 어노테이션(annotation) (0) | 2017.12.01 |
[JSP] 국제화태그,필터 (0) | 2017.12.01 |
[JSP] JSTL (0) | 2017.12.01 |
[JSP] <jsp:useBean>,Cookie,EL (0) | 2017.12.01 |