상세 컨텐츠

본문 제목

jsp sitemesh 공부 내용, 좋은 기능

관리X 과거글

by 까먹기전에 2015. 3. 26. 10:55

본문

반응형

=========================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>


============menu.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<a href="<%=request.getContextPath()%>/member/loginform.jsp">로그인</a><br/>
<a href="<%=request.getContextPath()%>/member/logout.jsp">로그아웃</a><br/>
============top.jsp
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<h1 align="center">서울IT교육센터</h1>
메인카테고리
============welcome.html
<%@ page language="java" contentType="text/html; charset=EUC-KR"
    pageEncoding="EUC-KR"%>
<!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>메인화면</title>
</head>
<body>
환영합니다~
</body>
</html>
====================================WebContent - hello - a.jsp================================
<%@ page language="java" contentType="text/html; charset=EUC-KR"
pageEncoding="EUC-KR"%>
<!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>a.jsp페이지입니다.</title>
<style type="text/css">
.a { color:blue; }
</style>
<script type="text/javascript">

</script>
</head>
<body>
<h1 class="a">a.jsp페이지입니다.</h1>
</body>
</html>



'관리X 과거글' 카테고리의 다른 글

자바 애노테이션 타겟지정,리텐션 지정  (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

관련글 더보기