프로그래밍/JSP

[JSP] jsp:include를 이용해서 페이지 불러오기

비전공개미 2022. 10. 12. 19:22
반응형
SMALL

top.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
TOP 메뉴 -
<a href="index.jsp?target=home">홈</a>
<a href="index.jsp?target=champ">챔피언정조</a>
<a href="index.jsp?target=tech">공략</a>
</body>
</html>

 

 

menu.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
<table>
  <tr><td>MENU</td></tr>
  <tr><td><a href="#">자료실</a></td></tr>
  <tr><td><a href="#">아이템정보</a></td></tr>
  <tr><td><a href="#">자유게시판</a></td></tr>
</table>
</body>
</html>

 

 

bottom.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
</head>
<body>
BOTTOM 부가 내용 -
<a href="#">회사소개</a> |
<a href="#">찾아오는길</a>
</body>
</html>

 

 

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<style>
	td { padding: 1em;}
</style>
</head>
<body>
<table border="1">
  <tr>
    <td colspan="2">
      <jsp:include page="module/top.jsp" flush="false" />
    </td>
  </tr>
  <tr>
    <td valign="top">
      <jsp:include page="module/left.jsp" flush="false" />
    </td>
    <td>
      레이아웃1<br><br>
    </td>
  </tr>
  <tr>
    <td colspan="2">
      <jsp:include page="module/bottom.jsp" flush="false" />
    </td>
  </tr>
</table>
</body>
</html>

 

 

페이지 include하는 방법

1. <%@ inlucde file="index.jsp" %>

2. <jsp:include page="index.jsp" flush="false" />

반응형
LIST