Search

JSP λ ˆμ΄μ•„μ›ƒ κ΅¬μ„±ν•˜κΈ°

JSP λ ˆμ΄μ•„μ›ƒ κ΅¬μ„±ν•˜κΈ°

β€’
ν”„λ‘œμ νŠΈ ꡬ쑰
β€’
정적 파일 μ€€λΉ„ν•˜κΈ°
β€’
라이브러리 μ€€λΉ„ν•˜κΈ°
β€’
μ˜μ—­ 파일 μ€€λΉ„ν•˜κΈ°
β—¦
jstl.jsp
β—¦
common.jsp
β—¦
header.jsp
β—¦
footer.jsp
β—¦
meta.jsp
β—¦
link.jsp
β—¦
script.jsp
β€’
메인 ν™”λ©΄ λ§Œλ“€κΈ°
β—¦
index.jsp
β—¦
μ˜μ—­ 파일 ν¬ν•¨ν•˜κΈ°
β–ͺ
μ•‘μ…˜νƒœκ·Έ <jsp:include>

ν”„λ‘œμ νŠΈ ꡬ쑰

πŸ“¦ project └── πŸ“‚ src β”œβ”€β”€ πŸ“‚ main β”œβ”€β”€ πŸ“‚ java β”‚ └── πŸ“‚ filter β”‚ └── πŸ“„ EncodingFilter.java └── πŸ“‚ webapp β”œβ”€β”€ πŸ“‚ WEB-INF β”‚ └── πŸ“‚ lib β”‚ β”œβ”€β”€ πŸ“„ lombok.jar β”‚ β”œβ”€β”€ πŸ“„ mysql-connector-j-9.0.0.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-compat-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-impl-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-jstlel-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-spec-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ jbcrypt-0.4.jar β”‚ └── πŸ“„ alcl-jdbc.jar β”œβ”€β”€ πŸ“‚ static β”‚ β”œβ”€β”€ πŸ“‚ css β”‚ β”‚ β”œβ”€β”€ πŸ“„ reset.css β”‚ β”‚ └── πŸ“„ style.css β”‚ β”œβ”€β”€ πŸ“‚ img β”‚ β”‚ └── πŸ“„ logo.png β”‚ └── πŸ“‚ js β”‚ └── πŸ“„ script.js └── πŸ“‚ layout β”œβ”€β”€ πŸ“„ jstl.jsp β”œβ”€β”€ πŸ“„ header.jsp β”œβ”€β”€ πŸ“„ footer.jsp β”œβ”€β”€ πŸ“„ meta.jsp β”œβ”€β”€ πŸ“„ link.jsp β”œβ”€β”€ πŸ“„ script.jsp └── πŸ“„ common.jsp └── πŸ“„ index.jsp
Plain Text
볡사

정적 파일 μ€€λΉ„ν•˜κΈ°

... └── πŸ“‚ webapp β”œβ”€β”€ πŸ“‚ static β”‚ β”œβ”€β”€ πŸ“‚ css β”‚ β”‚ β”œβ”€β”€ πŸ“„ reset.css β”‚ β”‚ └── πŸ“„ style.css β”‚ β”œβ”€β”€ πŸ“‚ img β”‚ β”‚ └── πŸ“„ logo.png β”‚ └── πŸ“‚ js β”‚ └── πŸ“„ script.js ...
Plain Text
볡사
β€’
css
β—¦
reset.css
β—¦
style.css
β€’
img
β—¦
logo.png
β€’
js
β—¦
script.js

reset.css

@charset "UTF-8"; @import url('https://fonts.googleapis.com/css2?family=Noto+Sans+KR&display=swap'); /*reset*/ * {margin: 0; padding: 0; box-sizing: border-box; } html, body, div, span, applet, object, iframe, h1, h2, h3, h4, h5, h6, p, blockquote, pre, a, abbr, acronym, address, big, cite, code, del, dfn, em, font, img, ins, kbd, q, s, samp, small, strike, strong, sub, sup, tt, var, b, u, i, center, dl, dt, dd, ol, ul, li, fieldset, form, label, legend, table, tbody, tfoot, thead, tr, th, td{margin:0;padding:0;} h1, h2, h3, h4, h5, h6 {font-weight: 700; font-size: inherit;} a {text-decoration: inherit; color: inherit;} li {list-style: none;} img {vertical-align: middle;} a img {border: none;} a:focus {outline: none} button:focus {outline: none} body { font-family: 'Noto Sans KR', sans-serif; } /* 글씨 λ“œλž˜κ·Έ μ‹œ, μƒνƒœλ₯Ό μ§€μ •ν•˜λŠ” μ„ νƒμž */ ::selection { background-color: var(--main-color); color: white; } /* ⭐ CSS λ³€μˆ˜ μ„ μ–Έ */ /* --λ³€μˆ˜λͺ… : κ°’ */ /* βœ… μ‚¬μš© : var(--λ³€μˆ˜λͺ…) */ /* html μ΅œμƒμœ„ μš”μ†Œ 선택 (html 선택보닀 높은 μš°μ„ μˆœμœ„ */ :root { /* πŸ‘©β€πŸŽ¨ 메인 컬러 */ --main-color : #DCE6FF; /* πŸ‘©β€πŸŽ¨ μ„œλΈŒ 컬러 */ --sub-color: #89B1FF; /* πŸ‘©β€πŸŽ¨ 폰트 μ‚¬μ΄μ¦ˆ */ --text-title: 32px; --text-normal: 16px; /* πŸ‘©β€πŸŽ¨ μ»¨ν…Œμ΄λ„ˆ μ‚¬μ΄μ¦ˆ */ --container-size: 1200px; --container-lg-size: 1400px; }
CSS
볡사

style.css

@charset "UTF-8"; .container, header, footer { width: var(--container-size); margin: 0 auto; } section { margin: 100px auto; min-height: 300px; } .text-title { font-size: 32px; }
CSS
볡사

logo.png

logo.png
1124.4KB

script.js

/** * */ document.addEventListener("DOMContentLoaded", function() { alert("Hello JSP~!"); })
JavaScript
볡사

라이브러리 μ€€λΉ„ν•˜κΈ°

... πŸ“‚ webapp β”œβ”€β”€ πŸ“‚ WEB-INF β”‚ └── πŸ“‚ lib β”‚ β”œβ”€β”€ πŸ“„ lombok.jar β”‚ β”œβ”€β”€ πŸ“„ mysql-connector-j-9.0.0.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-compat-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-impl-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-jstlel-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ taglibs-standard-spec-1.2.5.jar β”‚ β”œβ”€β”€ πŸ“„ jbcrypt-0.4.jar β”‚ └── πŸ“„ alcl-jdbc.jar ...
Plain Text
볡사

μ˜μ—­ 파일 μ€€λΉ„ν•˜κΈ°

β€’
jstl.jsp
β€’
common.jsp
β€’
header.jsp
β€’
footer.jsp
β€’
meta.jsp
β€’
link.jsp
β€’
script.jsp

jstl.jsp

<%-- JSTL --%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%> <%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions"%> <%@ taglib prefix="sql" uri="http://java.sun.com/jsp/jstl/sql"%> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>
Java
볡사

common.jsp

<%-- μ „μ—­λ³€μˆ˜ --%> <% // Context Path (루트 경둜) String root = request.getContextPath(); // 둜그인 아이디 (μ„Έμ…˜) String loginId = (String) session.getAttribute("loginId"); %>
Java
볡사

header.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/layout/common.jsp" %> <header> <img src="<%= root %>/static/img/logo.png" width="48" > <nav> <ul> <li><a href="<%= root %>/login.jsp">둜그인</a></li> <li><a href="<%= root %>/signup.jsp">νšŒμ›κ°€μž…</a></li> </ul> </nav> </header>
HTML
볡사

footer.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/layout/common.jsp" %> <footer> <p>Copyright ALOHA CLASS</p> </footer>
HTML
볡사

meta.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/layout/common.jsp" %> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <!-- <title>projectπŸ’» - ALOHA CLASS🌴</title> --> <!-- νŒŒλΉ„μ½˜ --> <link rel="icon" href="<%= root %>/static/img/logo.png" type="image/x-icon"> <!-- 썸넀일 이미지 μ„€μ • --> <meta property="og:image" content="https://i.imgur.com/yiTQ3EV.jpg"> <!-- μ›Ή νŽ˜μ΄μ§€ μ„€λͺ… (선택 사항) --> <meta property="og:description" content="ALOHA CLASS🌴 - μ‡Όν•‘λͺ° ν”„λ‘œμ νŠΈ"> <!-- μ›Ή νŽ˜μ΄μ§€ URL --> <meta property="og:url" content="<%= root %>"> <!-- μ›Ή νŽ˜μ΄μ§€ 제λͺ© --> <meta name="title" content="projectπŸ’» - ALOHA CLASS🌴"> <meta property="og:title" content="projectπŸ’» - ALOHA CLASS🌴"> <!-- μ›Ή νŽ˜μ΄μ§€ νƒ€μž… (μ›Ήμ‚¬μ΄νŠΈ, 기사, μ œν’ˆ λ“±) --> <meta property="og:type" content="website"> <!-- 검색어 --> <meta name="keywords" content="μ‡Όν•‘λͺ° ν”„λ‘œμ νŠΈ, μžλ°” μ›Ήκ°œλ°œ, ALOHA CLASS, μ•Œλ‘œν•˜ 클래슀"> <meta name="robots" content="index, follow"> <!-- μ‚¬μ΄νŠΈ 맡 --> <link rel="sitemap" href="<%= root %>/static/sitemap.xml">
HTML
볡사

link.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/layout/common.jsp" %> <%-- 폰트 --%> <%-- 라이브러리 --%> <link href="<%= root %>/static/css/reset.css" rel="stylesheet" /> <link href="<%= root %>/static/css/style.css" rel="stylesheet" />
HTML
볡사

script.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ include file="/layout/common.jsp" %> <%-- 라이브러리 --%> <%-- jQuery --%> <script src="<%= root %>/static/js/script.js"></script>
HTML
볡사

메인 ν™”λ©΄ λ§Œλ“€κΈ°

β€’
index.jsp
β€’
μ˜μ—­ 파일 ν¬ν•¨ν•˜κΈ°
β—¦
λ””λ ‰ν‹°λΈŒ νƒœκ·Έ <%@ include %>
β—¦
μ•‘μ…˜νƒœκ·Έ <jsp:include>
β€’
λ ˆμ΄μ•„μ›ƒ μ™„μ„±

index.jsp

<%@ include file="/layout/jstl.jsp" %> <%@ include file="/layout/common.jsp" %> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html> <head> <title>projectπŸ’» - ALOHA CLASS🌴</title> <jsp:include page="/layout/meta.jsp" /> <jsp:include page="/layout/link.jsp" /> </head> <body> <jsp:include page="/layout/header.jsp" /> <%-- [Contents] ######################################################### --%> <div class="container"> <section> <h1 class="text-title">메인 ν™”λ©΄</h1> <h3>projectπŸ’» - ALOHA CLASS🌴</h3> </section> </div> <%-- [Contents] ######################################################### --%> <jsp:include page="/layout/footer.jsp" /> <jsp:include page="/layout/script.jsp" /> </body> </html>
HTML
볡사