Search

메인 ν™”λ©΄

κ²Œμ‹œνŒ 메인 ν™”λ©΄

μž‘μ—…μˆœμ„œ

1.
web.xml - <welcome-file-list> νƒœκ·Έ μž‘μ„±
2.
index.jsp νŽ˜μ΄μ§€ 생성
3.
μ½”λ“œ μž‘μ„±

web.xml

<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://xmlns.jcp.org/xml/ns/javaee" xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_4_0.xsd" id="WebApp_ID" version="4.0"> <display-name>Board</display-name> <welcome-file-list> <welcome-file>index.html</welcome-file> <welcome-file>index.jsp</welcome-file> <welcome-file>index.htm</welcome-file> <welcome-file>default.html</welcome-file> <welcome-file>default.jsp</welcome-file> <welcome-file>default.htm</welcome-file> </welcome-file-list> </web-app>
HTML
볡사
<welcome-file-list> <welcome-file>초기 파일λͺ…</welcome-file> </welcome-file-list>
μ„€λͺ…
ν΄λΌμ΄μ–ΈνŠΈκ°€ μ›Ή μ• ν”Œλ¦¬μΌ€μ΄μ…˜ 루트 URL에 μ ‘κ·Όν•  λ•Œ μžλ™μœΌλ‘œ ν‘œμ‹œλ˜λŠ” 초기 νŽ˜μ΄μ§€λ₯Ό μ •μ˜ν•˜λŠ” 데 μ‚¬μš©λ©λ‹ˆλ‹€.
μ—¬κΈ°μ„œ μ›Ή νŽ˜μ΄μ§€ 초기 화면을 μ„€μ •ν•˜μ˜€κΈ° λ•Œλ¬Έμ—, μ„œλ²„μ˜ 루트 κ²½λ‘œμ— μ ‘κ·Όν–ˆμ„ λ•Œ index.jsp λ₯Ό λ³Ό 수 μžˆμŠ΅λ‹ˆλ‹€.

index.jsp

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html> <html data-bs-theme="light"> <head> <meta charset="UTF-8"> <jsp:include page="/layout/main/import/meta.jsp" /> <jsp:include page="/layout/main/import/link.jsp" /> </head> <body> <jsp:include page="/layout/main/UI/header.jsp" /> <div class="container"> <div class="px-4 pt-5 my-5 text-center border-bottom"> <h1 class="display-4 fw-bold">κ²Œμ‹œνŒ ν”„λ‘œμ νŠΈ</h1> <div class="col-lg-6 mx-auto"> <p class="lead mb-4">JSP κ²Œμ‹œνŒ ν”„λ‘œμ νŠΈ μž…λ‹ˆλ‹€.</p> <div class="d-grid gap-2 d-sm-flex justify-content-sm-center mb-5"> <button type="button" class="btn btn-primary btn-lg px-4 me-sm-3">κ²Œμ‹œκΈ€ λͺ©λ‘</button> <button type="button" class="btn btn-outline-secondary btn-lg px-4">둜그인</button> </div> </div> <div class="overflow-hidden"> <div class="container px-5"> <img src="https://i.imgur.com/pPxobUQ.jpg" class="img-fluid border rounded-3 shadow-lg mb-4" alt="κ²Œμ‹œνŒ ν”„λ‘œμ νŠΈ" width="700" height="500" loading="lazy"> </div> </div> </div> </div> <jsp:include page="/layout/main/UI/footer.jsp" /> <jsp:include page="/layout/main/import/script.jsp" /> </body> </html>
HTML
볡사
code
<jsp:include page="파일λͺ….jsp" />
HTML
볡사
μ„€λͺ…
<jsp:include> λŠ” JSP μ•‘μ…˜ νƒœκ·Έλ‘œ μ™ΈλΆ€ JSP νŽ˜μ΄μ§€ νŒŒμΌμ„ ν•΄λ‹Ή νŒŒμΌμ— ν¬ν•¨μ‹œν‚€λŠ” νƒœκ·Έμž…λ‹ˆλ‹€.
μ—¬κΈ°μ„œλŠ”, meta.jsp, link.jsp, header.jsp, footer.jsp, script.jsp λ₯Ό ν¬ν•¨μ‹œν‚€κ³  μžˆμŠ΅λ‹ˆλ‹€. μ΄λ ‡κ²Œ ν•¨μœΌλ‘œμ¨ 또 μƒˆλ‘œμš΄ 화면을 κ°œλ°œν•  λ•Œ, 맀번 κ³΅ν†΅μ μœΌλ‘œ μ“°μ΄λŠ” μ˜μ—­μ˜ νƒœκ·Έλ₯Ό 쀑볡 ν•˜μ—¬ μž‘μ„±ν•˜μ§€ μ•Šμ•„λ„ λ©λ‹ˆλ‹€. λ˜ν•œ, 헀더 μ˜μ—­ μˆ˜μ • μ‹œ, λ‹€μˆ˜μ˜ μ€‘λ³΅λœ μ½”λ“œλ₯Ό 번거둭게 μˆ˜μ •ν•˜μ§€ μ•Šμ•„λ„ header.jsp 파일 ν•˜λ‚˜λ§Œ μˆ˜μ •ν•˜λ©΄ 되기 λ•Œλ¬Έμ— μœ μ§€λ³΄μˆ˜ν•˜κΈ° 쉽고 생산성이 λ†’μ•„μ§‘λ‹ˆλ‹€. μ΄λŸ¬ν•œ μž‘μ—…μ„ ν…œν”Œλ¦Ώ μž‘μ—…μ΄λΌκ³  λΆ€λ¦…λ‹ˆλ‹€.
메인화면을 μ™„μ„±ν•˜μ˜€μŠ΅λ‹ˆλ‹€. 이제 κ²Œμ‹œνŒ ν”„λ‘œμ νŠΈμ˜ μ£Όμš” κΈ°λŠ₯듀을 ν•˜λ‚˜μ”© κ°œλ°œν•΄ λ‚˜κ°€λ³΄λ„λ‘ ν•˜κ² μŠ΅λ‹ˆλ‹€.