MapleStory Finger Point

๐ŸŸค JAVA/๐ŸŸค Spring 41

[SpringBoot] thymeleaf ํƒ€์ž„๋ฆฌํ”„ ๊ฐœ๋…

โ—ˆ  thymeleaf ํƒ€์ž„๋ฆฌํ”„Thymeleaf๋Š” ์„œ๋ฒ„ ์‚ฌ์ด๋“œ Java ํ…œํ”Œ๋ฆฟ ์—”์ง„์œผ๋กœSpring Boot์—์„œ ์ž์ฃผ ์‚ฌ์šฉ๋˜๋Š” ๋ทฐ ํ…œํ”Œ๋ฆฟ ๊ธฐ์ˆ ์ด๋‹ค. jstl ๊ณผ ๋น„์Šทํ•˜๋‹ค. ๋ถ€ํŠธ๋Š” ๊ฐ€๋Šฅํ•˜๋ฉด jsp ๋ฅผ ํ”ผํ•˜๊ณ  thymel๊ฐ™์€ view ํ…œํ”Œ๋ฆฟ ์—”์ง„์„ ์‚ฌ์šฉํ•˜๋ผ๊ณ  ๊ถŒ์žฅํ•œ๋‹ค. !! ํ”„๋กœ์ ํŠธ๋ฅผ ์‹œ์ž‘ํ•  ๋•Œ, ๊ธฐ๋ณธ์ ์œผ๋กœ ํ™”๋ฉด ํ…œํ”Œ๋ฆฟ ์—”์ง„์ด ์„ค์ •๋˜์–ด ์žˆ์ง€ ์•Š๊ธฐ ๋•Œ๋ฌธ์—,์›น ์• ํ”Œ๋ฆฌ์ผ€์ด์…˜์˜ ๋ทฐ(View) ์ฒ˜๋ฆฌ๋ฅผ ์œ„ํ•ด Thymeleaf์™€ ๊ฐ™์€ ํ…œํ”Œ๋ฆฟ ์—”์ง„์„ ์ถ”๊ฐ€    โ—ˆ ํƒ€์ž„๋ฆฌํ”„ ์‹œ์ž‘ํ•˜๊ธฐ1. ํƒ€์ž„๋ฆฌํ”„ ์˜์กด์„ฑ ์ถ”๊ฐ€ํ•˜๊ธฐimplementation 'org.springframework.boot:spring-boot-starter-thymeleaf'2. html ํŒŒ์ผ๋กœ ์ž‘์„ฑํ•œ๋‹ค.3. ์ตœ์ƒ๋‹จ์—  xmlns:th ๋ช…์‹œํ•ด์ค€๋‹ค. (๋ช…์‹œํ•ด์ฃผ๋Š” ํŽธ์ด..

[Spring] XML & Annotation ์„ค์ • (+ ์–ด๋…ธํ…Œ์ด์…˜ ์ •๋ฆฌ)

๋ชฉ์ฐจ  1. xml ๊ธฐ๋ฐ˜ ์„ค์ •`applicationContext.xml` ๊ฐ™์€ ์„ค์ •ํŒŒ์ผ์— Bean ์„ ์„ค์ •ํ•˜๋Š” ๋ฐฉ๋ฒ•  `` : xml ์„ค์ •์˜ ์ตœ์ƒ์œ„ ์š”์†Œ, Bean ์ •์˜`` : ์‹ค์ œ Bean ์„ ์ •์˜ํ•˜๋Š” ์š”์†Œ id ๋Š” Bean ์ด๋ฆ„ / class ๋Š” Bean ๊ตฌํ˜„ ํด๋ž˜์Šค`` : ๊ฐ์ฒด๋ฅผ ์ฃผ์ž…ํ•˜๋Š” ๋ถ€๋ถ„ , ref ์†์„ฑ์€ ๋‹ค๋ฅธ Bean ์ด๋ฆ„์„ ์ฐธ์กฐํ•˜์—ฌ ์ฃผ์ž…   2. ์–ด๋…ธํ…Œ์ด์…˜ ๋ฐฉ์‹ Spring ์—์„œ๋Š” ๋‹ค์–‘ํ•œ ์Šคํ…Œ๋ ˆ์˜คํƒ€์ž… ์–ด๋…ธํ…Œ์ด์…˜ ์„ ์‚ฌ์šฉํ•˜์—ฌ Bean ์„ ์ •์˜ํ•  ์ˆ˜ ์žˆ๋‹ค. !์ฝ”๋“œ๋‚ด์—์„œ ์„ค์ • ์ฒ˜๋ฆฌ๋ฅผ ํ•˜๊ธฐ ๋•Œ๋ฌธ์—, ์„ค์ •์ด ๊ฐ„๊ฒฐํ•˜๊ณ  ํŽธ๋ฆฌํ•ด์ง„๋‹ค. โ˜บ๏ธ * ์Šคํ…Œ๋ ˆ์˜คํƒ€์ž… ์–ด๋…ธํ…Œ์ด์…˜ : Spring Framework์—์„œ ๋นˆ์„ ์ •์˜ํ•  ๋•Œ ์‚ฌ์šฉ๋˜๋Š” ํŠน์ˆ˜ํ•œ ์ข…๋ฅ˜์˜ ์–ด๋…ธํ…Œ์ด์…˜  @Comp..

[Spring] request, response

//voidํ˜•์€ ๋“ค์–ด์˜จ ์š”์ฒญ ๊ฒฝ๋กœ๊ฐ€, ๋‚˜๊ฐ€๋Š” ๊ฒฝ๋กœ๊ฐ€ ๋ฉ๋‹ˆ๋‹ค(ํ™”๋ฉด๊ฒฝ๋กœ) @RequestMapping("/req_ex01") public void ex01() { } @RequestMapping("/req_ex01") public String ex01() { return "request/req_ex01"; //ํ™”๋ฉด๊ฒฝ๋กœ }   //@RequestMapping(value = "/basic", method = RequestMethod.GET) //get๋งŒ ํ—ˆ์šฉํ•จ //@RequestMapping(value = "/basic", method = RequestMethod.POST) //post๋งŒ ํ—ˆ์šฉํ•จ //@RequestMapping("/basic") //get, post ๋‘˜๋‹ค ํ—ˆ์šฉํ•จ @Reques..

[Spring / ์‹ค์Šต1] ์ ์ˆ˜ ๋“ฑ๋ก ํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ (์™„์„ฑโญ)

์ด๋ฆ„๊ณผ ์ ์ˆ˜๋ฅผ ์ž…๋ ฅํ•œ ํ›„  [์ ์ˆ˜ ๋“ฑ๋ก] ๋ฒ„ํŠผ์„ ๋ˆ„๋ฅธ๋‹ค.      ์ ์ˆ˜๊ฐ€ ์ž˜ ๋“ฑ๋ก๋˜์—ˆ๋‹ค๋Š” ํ™”๋ฉด์ด ๋œฌ๋‹ค.     [๋ชฉ๋กํŽ˜์ด์ง€] ๋ฅผ ๋ˆ„๋ฅด๋ฉด ์ด๋ ‡๊ฒŒ ๋“ฑ๋ก๋˜์–ด์žˆ๋Š” ํ‘œ๊ฐ€ ๋œจ๊ณ     [์ ์ˆ˜๋“ฑ๋ก] or [์ถ”๊ฐ€๋“ฑ๋กํ•˜๊ธฐ] ๋งํฌ๋ฅผ ๋ˆ„๋ฅด๋ฉด ๋‹ค์‹œ ๋“ฑ๋ก ํŽ˜์ด์ง€๋กœ ์ด๋™ํ•œ๋‹ค.    ๋ฐ์ดํ„ฐ๋ฒ ์ด์Šค์—๋„ ๊ฐ’์ด ์ž˜ ๋“ค์–ด์˜ด์„ ํ™•์ธ ๊ฐ€๋Šฅํ•˜๋‹ค!

[Spring / ์‹ค์Šต1] ์ ์ˆ˜ ๋“ฑ๋ก ํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ (Service, Controller)

1) Service interface / Service impl ๋งŒ๋“ค๊ธฐ ๐Ÿ’€Service interfacemapper ์™€ ๋ฉ”์„œ๋“œ๋ช…์„ ํ†ต์ผ์‹œ์ผœ์ค€๋‹ค (์ผ๊ด€์„ฑ, ๊ฐ€๋…์„ฑ)package com.simple.basic.service.score;import java.util.ArrayList;import com.simple.basic.command.ScoreVO;public interface ScoreService { public void regist(ScoreVO vo); //๋“ฑ๋ก public ArrayList getScore(); //์กฐํšŒ public void delete(int sno); //์‚ญ์ œ}  ๐Ÿ’€Service implements@Service("x")์—์„œ "x"๋Š” ์ด ์„œ๋น„์Šค ๋นˆ์˜ ์ด๋ฆ„์„ ์ง€์ •ํ•˜๋Š” ์—ญํ• ..

[Spring / ์‹ค์Šต1] ์ ์ˆ˜ ๋“ฑ๋ก ํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ (DB,VO,Mapper)

1) Oracle database :: TABLE ์ƒ์„ฑ CREATE TABLE SCORE( SNO NUMBER(10), NAME VARCHAR2(30), KOR VARCHAR2(30), ENG VARCHAR2(30), MATH VARCHAR2(30));ALTER TABLE SCORE ADD CONSTRAINT SCORE_SNO_PK PRIMARY KEY (SNO); -- PKCREATE SEQUENCE SCORE_SEQ NOCACHE; --์‹œํ€€์Šค   2) VO ๋งŒ๋“ค๊ธฐ ๋”๋ณด๊ธฐpackage com.simple.basic.command;public class ScoreVO { private int sno; private String name; private String kor; p..

[Spring / ์‹ค์Šต1] ์ ์ˆ˜ ๋“ฑ๋ก ํŽ˜์ด์ง€ ๋งŒ๋“ค๊ธฐ (UI, ํ™”๋ฉด์ œ์ž‘)

1) ์ ์ˆ˜ ๋“ฑ๋ก ํŽ˜์ด์ง€์—์„œ ์ ์ˆ˜๋ฅผ ๋“ฑ๋กํ•˜๋ฉด2) ๋“ฑ๋ก์ด ๋˜์—ˆ๋‹ค๋Š” ๊ฒฐ๊ณผ ํ™”๋ฉด์ด ๋œฌ๋‹ค. 3) ์ดํ›„ ๋ฆฌ์ŠคํŠธ ํ™”๋ฉด์œผ๋กœ ์ด๋™ํ•˜๋ฉด ๋“ฑ๋กํ•œ ์ ์ˆ˜๋ฅผ ๋ฆฌ์ŠคํŠธ๋ฅผ ๋ณผ ์ˆ˜ ์žˆ๋‹ค.  1)  UI ์ œ์ž‘ ( jsp ํ™”๋ฉด ๊ตฌ์„ฑํ•˜๊ธฐ ) scoreRegist.jspscoreResult.jspscoreList.jsp  [code] scoreRegist.jsp๋”๋ณด๊ธฐ ์ด๋ฆ„: ๊ตญ์–ด: ์ˆ˜ํ•™: ์˜์–ด:   [code] scoreResult.jsp ๋”๋ณด๊ธฐ ์ ์ˆ˜ ๋“ฑ๋ก์ด ์ •์ƒ์ฒ˜๋ฆฌ๋˜์—ˆ์Šต๋‹ˆ๋‹ค! ๋ชฉ๋กํŽ˜์ด์ง€ ์ ์ˆ˜๋“ฑ๋ก   [code] scoreList.jsp ๋”๋ณด๊ธฐ ${a.index } ${vo.name } ${vo.kor } ${vo.eng } ${vo.math } ์‚ญ์ œ ์ถ”๊ฐ€๋“ฑ๋กํ•˜๊ธฐ