JAVA OPEN API2013. 6. 19. 18:20

네이버  : "sitemesh(사이트메쉬) 해보기" 검색하면 나옴

http://cafe.naver.com/buldon/2005

 

1. jar파일 다운로드 ( http://opensymphony.com/  프로젝트 임 )

  http://www.sitemesh.org/ - > download  ( sitemesh-버전.jar , 최신 2.4.2 )

 

2. web.xml 설정 추가

 <!-- Sitemesh Configration -->
 <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 설정

 <?xml version="1.0" encoding="UTF-8"?>
<decorators defaultdir="/decorators">
    <decorator name="basic-theme" page="basic-theme.jsp">
        <pattern>/data/*</pattern>
    </decorator>
</decorators>

4. basic-theme.jsp 파일

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Café Mirabeau</title>
</head>
<body>
    <h1>Header</h1>
    <p><b>Navigation</b></p>   
    <hr />
    <decorator:body />    
    <hr />
    <h1>Footer</h1>
</body>
</html>

 

5. /data/hour.jsp      ( 화면에 보일때는 basic-theme.jsp 안에 hour.jsp파일의 body가 자동으로 들어가서 보인다 )

<html xmlns="http://www.w3.org/1999/xhtml">
<head>
    <title>Hours</title>
</head>
<body>
    <h1>Weekdays</h1>
    <p>5:00pm - 10:00pm</p>
    <p>Weekends</p>
    <p>5:00pm - 10:00pm</p>
</body>
</html>

 

sitemesh에서 제공하는 파일   cafe.war

Posted by 선한열심