๋ณธ๋ฌธ ๋ฐ”๋กœ๊ฐ€๊ธฐ
Back-End/SPRING

SPRING] ์ดˆ๊ธฐ ์„ค์ • , ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ ๋ฐฉ๋ฒ•

by bamDal 2022. 5. 23.

 

1. ์›Œํฌ์ŠคํŽ˜์ด์Šค ์žฌ์„ค์ •

SPRING ํด๋” ์ƒ์„ฑ > sts ์—์„œ ์›Œํฌ์ŠคํŽ˜์ด์Šค ์œ„์น˜ ๋‹ค์‹œ ์žก์•„์ฃผ๊ธฐ

 

2. sts ์„ค์ •

window > preferences >

1) general > web  browser , workspace

Web Browser์—์„œ use external web browser , Chrome
Workspace์—์„œ Text file encoding ์„ UTF-8๋กœ ๋ณ€๊ฒฝ

 

2) Web > CSS/ HTML/ JSP Files

Encoding ์„ค์ • UTF-8๋กœ ๋ณ€๊ฒฝ

 

 

3. ํ”„๋กœ์ ํŠธ ์ดˆ๊ธฐ ์„ค์ •

1) ๋ ˆ๊ฑฐ์‹œ ํ”„๋กœ์ ํŠธ ์ƒ์„ฑ

Package Explorer ์—์„œ ์šฐํด๋ฆญ > new > Spring Legacy Project

 

Spring MVC Project ์„ ํƒ > Project name ์ ๊ธฐ

 

top-level package ์ด๋ฆ„ ์„ค์ •

Finish! -> ์ดˆ๊ธฐ์—๋Š” ๋ญ”๊ฐ€ ๋‹ค์šด๋ฐ›์„๊ฑฐ๋ƒ ๋ฌป๋Š”๋ฐ yes ๋ˆŒ๋Ÿฌ์ฃผ๋ฉด ๋œ๋‹ค.

 

2) ๋Ÿฐ ์„œ๋ฒ„ ์ดˆ๊ธฐ ์„ค์ •

ํ”„๋กœ์ ํŠธ ์ด๋ฆ„์—์„œ ์šฐํด๋ฆญ > Run As > Run On Server

JSP ์—์„œ ์„ค์ •ํ•œ ๊ฒƒ๊ณผ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ๋งž๋Š” ๋ฒ„์ „์˜ ํ†ฐ์บฃ ์„ ํƒ
ํ†ฐ์บฃ ๋””๋ ‰ํ„ฐ๋ฆฌ : ๋‹ค์šด๋ฐ›์•„ ๋†“์€ ํ†ฐ์บฃ์˜ ์œ„์น˜ ์žก์•„์ฃผ๊ธฐ , JRE : ์„ ํƒ์ฐฝ ๋ˆŒ๋Ÿฌ์„œ ์žˆ๋Š” ๊ฑฐ ์„ ํƒ - ์ดˆ๊ธฐ์— ์„ค์ •๋˜์–ด์žˆ๋Š” workbench... ๋งŒ ์•„๋‹ˆ๋ฉด ๋จ.

 

next ๋ˆŒ๋Ÿฌ์„œ ์‹คํ–‰์‹œํ‚ฌ ํ”„๋กœ์ ํŠธ๋งŒ ๋‚จ๊ธฐ๊ณ  ๋‹ค๋ฅธ ํ”„๋กœ์ ํŠธ๋Š” remove all ํ•ด์ค€๋‹ค.

์‹คํ–‰ํ•˜๋ฉด ๋ฐฉํ™”๋ฒฝ ํ—ˆ์šฉ ์•Œ๋ฆผ์ฐฝ์ด ๋œจ๋Š”๋ฐ ํ—ˆ์šฉํ•ด์ฃผ๋ฉด ์›นํŽ˜์ด์ง€์—์„œ ๋œฌ๋‹ค.

ํ†ฐ์บฃ ์„ค์ •์€ jsp์™€ ๋งˆ์ฐฌ๊ฐ€์ง€๋กœ ํ•œ ๋ฒˆ๋งŒ ํ•ด์ฃผ๋ฉด ๋œ๋‹ค.

 

3) JSP ํŒŒ์ผ ์„ค์ •

new > other > jsp file

Next๋ฅผ ๋ˆŒ๋Ÿฌ์ค€๋‹ค.

 

html5๋ฅผ ์„ ํƒ ํ›„ ํŒŒ๋ž€ ๋ฐ‘์ค„์ด ์ณ์ ธ์žˆ๋Š” JSP Templates ๋ฅผ ๋ˆŒ๋Ÿฌ์ค€๋‹ค.
template ํŒจํ„ด์„ ์•ž์œผ๋กœ ์‚ฌ์šฉ์— ์•Œ๋งž๊ฒŒ ์„ค์ •

<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<link rel="stylesheet" href="resources/css/common.css" type="text/css">
<style></style>
</head>
<body>
	<table>
		<thead>
			<tr>
				<th>๋ฒˆํ˜ธ</th>
				<th>์ œ๋ชฉ</th>
				<th>๊ธ€์“ด์ด</th>
				<th>์กฐํšŒ์ˆ˜</th>
				<th>์‚ญ์ œ</th>
			</tr>
		</thead>
		<tbody>
			<c:forEach items="${list}" var="dto">
				<tr>
					<td>${dto.idx}</td>
					<td><a href="detail.do?idx=${dto.idx}">${dto.subject}</a></td>
					<td>${dto.user_name}</td>
					<td>${dto.bHit}</td>
					<td><a href="del.do?idx=${dto.idx}">์‚ญ์ œ</a></td>
				</tr>
			</c:forEach>
		</tbody>
	</table>
</body>
<script></script>
</html>

OK๋ฅผ ๋ˆ„๋ฅธ ํ›„ html5 ์„ ํƒ > finish

 

์•ž์œผ๋กœ spring์—์„œ ํ”„๋กœ์ ํŠธ๋ฅผ ๋งŒ๋“ค ๋•Œ๋Š” 3-1) ์ฒ˜๋Ÿผ Spring Legacy Project๋ฅผ ์„ ํƒํ•˜์—ฌ ๋งŒ๋“ ๋‹ค.