jsp๋ก header, footer ์ฐ๊ฒฐํ๊ธฐ
๋ฉ์ธ html์ header / footer ๋ฐ๋ก ๋ผ์ ๋ถ์ผ ์ ์๋ ๋ฐฉ๋ฒ์ jquery์ include๋ฐฉ๋ฒ๋ฐ์ ์ฐพ์ง ๋ชปํ๋ค.
(์ด๊ฒ๋ ๋ก์ปฌ์ด ์๋ ์๋ฒ ํ๊ฒฝ์์๋ง ๋ณผ ์ ์์.)
jsp๋ ๋ฌผ๋ก ์๋ฒ์์๋ง ํ์ธ ๊ฐ๋ฅํ์ง๋ง jquery๊ฐ ์๋ jsp๋ก ์ง์ header, footer๋ฅผ ๋ฐ๋ก ๋ง๋ค์ด์ ๋ผ๋ ๋ฐฉ๋ฒ์ ์์๋ณด์.
- ์ธํ
- VScode ํ์.
- tomcat ์ค์น.
- ๊ทธ์ธ ๋๋จธ์ง๋ vscode์ ํ์ฅ ํ๋ก๊ทธ๋จ์ผ๋ก ์ค์น.
์ธํ - tomcat ์ค์น.
vscode๋ก JSP ํ๊ฒฝ๊ตฌ์ฑ์ ํ๊ธฐ ์ํด์๋ tomcat ์ค์น๊ฐ ํ์ํ๋ค.
์๋ ๋ธ๋ก๊ทธ๋ฅผ ๋ณด๊ณ ์์๋๋ก ์ค์น.
https://nevertrustbrutus.tistory.com/245
header / footer jsp ๋ก ๋๋๊ธฐ
์ผ๋จ ๋ด๊ฐ ์์ ํ ๊ฒฝ๋ก๋ tomcat_vs ํด๋์์ ์์
.
โโโ tomcat_vs
โโโ index.jsp
โโโ sub.jsp
โโโ header.css
โโโ footer.css
โโโ common
โโโ header.jsp
โโโ footer.jsp
โโโ common.css
index.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>index</title>
<link rel="stylesheet" href="common/common.css">
</head>
<body>
<header>
<jsp:include page="common/header.jsp" />
</header>
<main>
<h1>index.jsp ํ์ผ์
๋๋ค.</h1>
<a href="sub.jsp">sub.jsp์ด๋</a>
</main>
<footer>
<jsp:include page="common/footer.jsp" />
</footer>
</body>
</html>
sub.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>sub</title>
<link rel="stylesheet" href="common/common.css">
</head>
<body>
<header>
<jsp:include page="common/header.jsp" />
</header>
<main>
<h1>sub.jsp ํ์ผ์
๋๋ค.</h1>
<a href="index.jsp">index.jsp์ด๋</a>
</main>
<footer>
<jsp:include page="common/footer.jsp" />
</footer>
</body>
</html>
header.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<link rel="stylesheet" href="../header.css">
<h1>header.jsp ํ์ผ์
๋๋ค.</h1>
<ul>
<li>header</li>
<li>header</li>
<li>header</li>
<li>header</li>
<li>header</li>
</ul>
footer.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<link rel="stylesheet" href="../footer.css">
<h1>footer.jsp ํ์ผ์
๋๋ค.</h1>
<ul>
<li>footer</li>
<li>footer</li>
<li>footer</li>
<li>footer</li>
<li>footer</li>
<li>footer</li>
</ul>
common.css ==> index.jsp์ ๋งํฌ
@charset "utf-8";
* { margin: 0; padding: 0; box-sizing: border-box; }
li { list-style: none; }
/* header */
ul li { display: inline-block; color: #222; }
/* main */
h1 { color: green; }
header.css ==> header.jsp์ include
h1 { color: red; }
footer.css ==> footer.jsp์ include
h1 { color: orange; }
๊ฒฐ๊ณผ
footer.css์ ๋ง์ง๋ง h1 { color: orange; }
๊ฐ ๋ชจ๋ ์ ์ฉ๋์๋ค.
ํ์ด์ง ์์ค๋ฅผ ๋ณด๋ฉด css๊ฐ ๋ชจ๋ ๊ฑธ๋ ค์์ผ๋ฏ๋ก ๊ณตํต๋ ํ๊ทธ๋ ํด๋์ค๋ ๊ฐ์ฅ ์๋์ ์๋ footer.css์ ์ ์ฉ๋ ์คํ์ผ๋ก ์ฒ๋ฆฌ๋๋ค.
์ฐธ๊ณ
๋ค์ค์๋ฒ๋ง๋๋ ๋ฐฉ๋ฒ
https://gutmate.github.io/2017/04/13/tomcat-multi/
include ํ๋ ๋ฐฉ๋ฒ
https://all-record.tistory.com/106
https://attibook.tistory.com/85
'๐etc' ์นดํ ๊ณ ๋ฆฌ์ ๋ค๋ฅธ ๊ธ
[plugIn] ๋๋์ฐจํธ(์ํ์ฐจํธ) (0) | 2021.10.19 |
---|---|
vw To pixel (px) Converter // vw๋ฅผ px๋ก ๋ฐ๊พธ๊ธฐ (0) | 2021.08.11 |
[plugIn] ๋ฐ์ํ ์ด๋ฏธ์ง ๋งํฌ ๊ฑธ๊ธฐ(jQuery-rwdImageMaps) (0) | 2021.08.10 |
[PlugIn] slick slider (0) | 2020.04.07 |
[Tistory] ํฐ์คํ ๋ฆฌ ๋งํฌ๋ค์ด ์ ์ฉํ๊ธฐ (0) | 2020.01.31 |