Search

Request

Request

: HTTP Request(μš”μ²­)λŠ” ν΄λΌμ΄μ–ΈνŠΈκ°€ μ„œλ²„λ‘œ λ³΄λ‚΄λŠ” μš”μ²­ λ©”μ‹œμ§€λ‘œ, μ›Ή λ¦¬μ†ŒμŠ€μ— λŒ€ν•œ λ™μž‘(GET, POST, λ“±) 및 ν•΄λ‹Ή λ¦¬μ†ŒμŠ€μ™€ ν•¨κ»˜ μ „λ‹¬λ˜λŠ” 데이터λ₯Ό μ •μ˜ν•©λ‹ˆλ‹€.

Overview

β€’
ν΄λΌμ΄μ–ΈνŠΈκ°€ μ„œλ²„λ‘œ μš”μ²­μ„ λ³΄λ‚΄λŠ” 방법
β—¦
λΈŒλΌμš°μ €λ₯Ό 톡해 μš”μ²­ 보내기
β—¦
API 개발 및 ν…ŒμŠ€νŠΈ 도ꡬλ₯Ό 톡해 μš”μ²­ 보내기
β–ͺ
Postman
β–ͺ
Thunder Client
β€’
Thunder Client 둜 μš”μ²­ 보내보기
β€’
μŠ€ν”„λ§ λΆ€νŠΈλ‘œ μ„œλ²„μ—μ„œ μš”μ²­ 받아보기
β—¦
μš”μ²­ ν…ŒμŠ€νŠΈ
β–ͺ
Thunder Client 둜 μš”μ²­ ν…ŒμŠ€νŠΈ
β–ͺ
HTML form νƒœκ·Έλ‘œ μš”μ²­ ν…ŒμŠ€νŠΈ

ν΄λΌμ΄μ–ΈνŠΈκ°€ μ„œλ²„λ‘œ μš”μ²­μ„ λ³΄λ‚΄λŠ” 방법

β€’
λΈŒλΌμš°μ €λ₯Ό 톡해 μš”μ²­ 보내기
β€’
API 개발 및 ν…ŒμŠ€νŠΈ 도ꡬλ₯Ό 톡해 μš”μ²­ 보내기

λΈŒλΌμš°μ €λ₯Ό 톡해 μš”μ²­ 보내기

β€’
μ£Όμ†Œ ν‘œμ‹œμ€„μ— URL λ₯Ό μž…λ ₯ν•˜μ—¬ μš”μ²­ν•˜κΈ°
β€’
FORM 전솑 μš”μ²­ ν•˜κΈ°

μ£Όμ†Œ ν‘œμ‹œμ€„μ— URL을 μž…λ ₯ν•˜μ—¬ μš”μ²­ν•˜κΈ°:

β€’
HTTP μš”μ²­ λ©”μ†Œλ“œ: 일반적으둜 λΈŒλΌμš°μ €μ—μ„œ μ£Όμ†Œ ν‘œμ‹œμ€„μ— URL을 μž…λ ₯ν•˜μ—¬ μš”μ²­μ„ 보낼 λ•Œ μ‚¬μš©λ˜λŠ” HTTP λ©”μ„œλ“œλŠ” GETμž…λ‹ˆλ‹€.
β€’
νŠΉμ§•:
β—¦
GET λ©”μ„œλ“œλŠ” μ„œλ²„λ‘œλΆ€ν„° 정보λ₯Ό μš”μ²­ν•˜κ³  ν•΄λ‹Ή λ¦¬μ†ŒμŠ€μ— λŒ€ν•œ μš”μ²­μ„ λ³΄λƒ…λ‹ˆλ‹€.
β—¦
μ£Όμ†Œ ν‘œμ‹œμ€„μ— 직접 μž…λ ₯ν•˜λ―€λ‘œ, λΈŒλΌμš°μ €μ— μ˜ν•΄ κ°€μž₯ κ°„λ‹¨ν•˜κ²Œ μš”μ²­ν•  수 μžˆμŠ΅λ‹ˆλ‹€.
β—¦
주둜 μ›ΉνŽ˜μ΄μ§€λ₯Ό μš”μ²­ν•  λ•Œ μ‚¬μš©λ˜λ©°, URL에 쿼리 νŒŒλΌλ―Έν„°λ₯Ό ν¬ν•¨ν•˜μ—¬ 정보λ₯Ό 전달할 수 μžˆμŠ΅λ‹ˆλ‹€.

FORM 전솑 μš”μ²­ν•˜κΈ°:

β€’
HTTP μš”μ²­ λ©”μ†Œλ“œ: FORM μ „μ†‘μ—μ„œ μ‚¬μš©λ˜λŠ” κΈ°λ³Έ λ©”μ„œλ“œλŠ” GET λ˜λŠ” POSTμž…λ‹ˆλ‹€.
β€’
νŠΉμ§•:
β—¦
GET: 폼 데이터λ₯Ό URL의 μΏΌλ¦¬μŠ€νŠΈλ§μ— ν¬ν•¨ν•˜μ—¬ μ „μ†‘ν•©λ‹ˆλ‹€. 주둜 데이터 κ²€μƒ‰μ΄λ‚˜ μ‘°νšŒμ— μ‚¬μš©λ©λ‹ˆλ‹€. URL에 데이터가 λ…ΈμΆœλ˜λ©° 길이에 μ œμ•½μ΄ μžˆμŠ΅λ‹ˆλ‹€.
β—¦
POST: 폼 데이터λ₯Ό HTTP μš”μ²­μ˜ λ³Έλ¬Έ(body)에 ν¬ν•¨ν•˜μ—¬ μ „μ†‘ν•©λ‹ˆλ‹€. 데이터 길이에 μ œμ•½μ΄ μ—†κ³ , λ―Όκ°ν•œ 정보 전솑에 μ‚¬μš©λ©λ‹ˆλ‹€. μ•ˆμ „ν•˜κ³  데이터λ₯Ό λ…ΈμΆœμ‹œν‚€μ§€ μ•ŠμŠ΅λ‹ˆλ‹€.
<form action="/board/insert" method="POST" id="form"> <input type="text" name="title" placeholder="제λͺ©"> <input type="text" name="writer" placeholder="μž‘μ„±μž"> <textarea name="content" cols="40" rows="5" placeholder="λ‚΄μš©"></textarea> </form>
HTML
볡사

GET vs POST

GET

μš©λ„
β€’
μ„œλ²„λ‘œ 데이터λ₯Ό μš”μ²­ν•˜μ—¬ κ°€μ Έμ˜€λŠ” 데 μ‚¬μš©λ¨.
β€’
정보λ₯Ό κ²€μƒ‰ν•˜κ±°λ‚˜ μ‘°νšŒν•  λ•Œ μ‚¬μš©.
νŠΉμ§•
β€’
URL의 쿼리 νŒŒλΌλ―Έν„°λ₯Ό 톡해 데이터λ₯Ό 전달
β€’
길이에 μ œν•œμ΄ μžˆμ–΄ ν•œμ •λœ μ–‘μ˜ 데이터 전달에 적합.
β€’
λΈŒλΌμš°μ €μ—μ„œ 캐싱될 수 μžˆμ–΄, 반볡 μš”μ²­μ— μœ μš©ν•¨.

POST

μš©λ„
β€’
μ„œλ²„λ‘œ 데이터λ₯Ό μ „μ†‘ν•˜λŠ” 데 μ‚¬μš©λ¨.
β€’
μƒˆλ‘œμš΄ 데이터λ₯Ό μƒμ„±ν•˜κ±°λ‚˜ μ—…λ°μ΄νŠΈν•  λ•Œ μ‚¬μš©.
νŠΉμ§•
β€’
데이터λ₯Ό HTTP μš”μ²­μ˜ λ³Έλ¬Έ(body)에 ν¬ν•¨ν•˜μ—¬ 전달 (데이터가 URL에 λ…ΈμΆœλ˜μ§€ μ•ŠμŒ).
β€’
데이터 길이에 μ œν•œμ΄ μ—†μ–΄ 더 λ§Žμ€ μ–‘μ˜ 데이터 전달에 적합.
β€’
λ―Όκ°ν•œ 정보 전솑에 μ ν•©ν•˜λ©°, λ³΄μ•ˆμ„ μœ„ν•œ HTTPS μ‚¬μš© ꢌμž₯.

API 개발 ν…ŒμŠ€νŠΈ 도ꡬλ₯Ό 톡해 μš”μ²­ 보내기

API 개발 ν…ŒμŠ€νŠΈ 도ꡬ

: κ°œλ°œμžκ°€ APIλ₯Ό λ§Œλ“€κ³ , ν…ŒμŠ€νŠΈν•˜λ©°, λ””λ²„κΉ…ν•˜λŠ”λ° 도움을 μ£ΌλŠ” μ†Œν”„νŠΈμ›¨μ–΄ λ„κ΅¬μž…λ‹ˆλ‹€.

μ’…λ₯˜

β€’
Postman
β€’
Thunder Client (VSCODE)

Postman

β€’
API 개발, ν…ŒμŠ€νŠΈ 및 λ¬Έμ„œν™”μ— 널리 μ‚¬μš©λ˜λŠ” ν”Œλž«νΌ.
β€’
μ‚¬μš©μž μΉœν™”μ  μΈν„°νŽ˜μ΄μŠ€μ™€ λ‹€μ–‘ν•œ κΈ°λŠ₯을 μ œκ³΅ν•˜μ—¬ API ν…ŒμŠ€νŠΈ 및 디버깅이 μš©μ΄ν•¨.

Thunder Client (VSCODE)

κ²½λŸ‰ Rest API ν΄λΌμ΄μ–ΈνŠΈ μ΅μŠ€ν…μ…˜μœΌλ‘œ, Visual Studio Code용으둜 μ„€κ³„λœ κ°„λ‹¨ν•˜κ³  κΉ”λ”ν•œ λ””μžμΈμ„ κ°€μ§€κ³  μžˆμŠ΅λ‹ˆλ‹€.

Postman 으둜 μš”μ²­ 보내보기

1.
New
2.
HTTP Request
3.
Request μž‘μ„±
a.
μš”μ²­ λ©”μ†Œλ“œ : GET
4.
Send

New

HTTP Request

Request μž‘μ„±

1.
μš”μ²­ λ©”μ†Œλ“œ : GET

Send

응닡 λ©”μ‹œμ§€

{ "args": {}, "headers": { "Accept": "*/*", "Accept-Encoding": "gzip, deflate, br", "Host": "httpbin.org", "Postman-Token": "86f7879d-21ba-425e-a061-4d640b5dd900", "User-Agent": "PostmanRuntime/7.31.1", "X-Amzn-Trace-Id": "Root=1-6540f7d5-3e6af9f251d571d0093f073f" }, "origin": "114.201.106.211", "url": "https://httpbin.org/get" }
JSON
볡사

Thunder Client 둜 μš”μ²­ 보내보기

1.
VS CODE μ‹€ν–‰
2.
ν™•μž₯: λ§ˆμΌ“ν”Œλ ˆμ΄μŠ€ (Extension)
3.
Thnder Client 검색
4.
μ„€μΉ˜
5.
Thnder Client μ•„μ΄μ½˜ 클릭
6.
New Request
7.
Request μž‘μ„±
a.
μš”μ²­ λ©”μ†Œλ“œ : GET
8.
Send (μš”μ²­-Requset)
9.
κ²°κ³Ό 확인 (응닡-Response)

더 μžμ„Έν•œ μ‚¬μš©λ²•

μ„€μΉ˜

β€’
VS CODE μ‹€ν–‰
β€’
ν™•μž₯: λ§ˆμΌ“ν”Œλ ˆμ΄μŠ€ (Extension)
β€’
Thunder Client 검색

Thunder Client μ•„μ΄μ½˜ 클릭

New Request

Request μž‘μ„±

1.
μš”μ²­ λ©”μ†Œλ“œ : GET

Send

응닡 확인

μŠ€ν”„λ§ λΆ€νŠΈλ‘œ μ„œλ²„μ—μ„œ μš”μ²­ 받아보기

β€’
ν”„λ‘œμ νŠΈ ꡬ쑰
β€’
ν”„λ‘œμ νŠΈ ν™˜κ²½
β€’
μž‘μ—… 파일
β€’
μ‹€ν–‰ κ²°κ³Ό
β—¦
μš”μ²­ ν…ŒμŠ€νŠΈ
β–ͺ
GET
β–ͺ
POST
β–ͺ
PUT
β–ͺ
DELETE

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

spring-request/ β”œβ”€β”€ src/ β”‚ β”œβ”€β”€ main/ β”‚ β”‚ β”œβ”€β”€ java/ β”‚ β”‚ β”‚ └── com/ β”‚ β”‚ β”‚ └── joeun/ β”‚ β”‚ β”‚ └── springrequest/ β”‚ β”‚ β”‚ β”œβ”€β”€ controller/ β”‚ β”‚ β”‚ β”‚ └── BoardController.java
β”‚ β”‚ β”‚ β”œβ”€β”€ dto/ β”‚ β”‚ β”‚ β”‚ └── Board.java β”‚ β”‚ β”‚ β”œβ”€β”€ ServletInitializer.java β”‚ β”‚ β”‚ └── SpringRequestApplication.java β”‚ β”œβ”€β”€ resources/ β”‚ β”‚ β”œβ”€β”€ application.properties β”‚ β”‚ β”œβ”€β”€ static/ β”‚ β”‚ └── templates/ └── build.gradle

ν”„λ‘œμ νŠΈ ν™˜κ²½

β€’
Spring boot version : 3.3.5
β€’
Group Id : com.aloha
β€’
Artifact Id : spring-request
β€’
Java version : JDK 17
β€’
Packaging : WAR
β€’
Dependency
β—¦
Spring Web
β—¦
Spring Dev Tools
β—¦
Lombok

μž‘μ—… 파일

β€’
build.gradle
β€’
Board.java
β€’
BoardController.java
β€’
build.gradle
dependencies { implementation 'org.springframework.boot:spring-boot-starter-web' compileOnly 'org.projectlombok:lombok' developmentOnly 'org.springframework.boot:spring-boot-devtools' annotationProcessor 'org.projectlombok:lombok' providedRuntime 'org.springframework.boot:spring-boot-starter-tomcat' testImplementation 'org.springframework.boot:spring-boot-starter-test' }
SQL
볡사
β€’
Board.java
/** * Board * - κ²Œμ‹œκΈ€ 정보 */ @Data @NoArgsConstructor public class Board { private int boardNo; private String title; private String writer; private String content; private Date regDate; private Date updDate; private int views; public Board(String title, String writer, String content) { this.title = title; this.writer = writer; this.content = content; } }
Java
볡사
β€’
BoardController.java
/** * κ²Œμ‹œνŒ 컨트둀러 * - κ²Œμ‹œκΈ€ λͺ©λ‘ - [GET] - /board * - κ²Œμ‹œκΈ€ 쑰회 - [GET] - /board/10 * - κ²Œμ‹œκΈ€ 등둝 처리 - [POST] - /board * - κ²Œμ‹œκΈ€ μˆ˜μ • 처리 - [PUT] - /board * - κ²Œμ‹œκΈ€ μ‚­μ œ 처리 - [DELETE] - /board */ @Slf4j // 둜그 μ‚¬μš© μ–΄λ…Έν…Œμ΄μ…˜ // @Controller // ν•΄λ‹Ή 클래슀λ₯Ό 컨트둀러 μ—­ν• λ‘œ λΉˆλ“±λ‘ @RestController // @ResponseBody+@Controller : ν•΄λ‹Ή 클래슀λ₯Ό REST API 컨트둀러둜 λΉˆλ“±λ‘ @RequestMapping("/board") public class BoardController { /** * κ²Œμ‹œκΈ€ λͺ©λ‘ * [GET] * /board * - response : boardList * @return * @throws Exception */ @GetMapping(value="") public ResponseEntity<List<Board>> list() throws Exception { log.info("[GET] - /board"); List<Board> boardList = new ArrayList<>(); boardList.add(new Board("제λͺ©1", "μž‘μ„±μž1", "λ‚΄μš©1")); boardList.add(new Board("제λͺ©2", "μž‘μ„±μž2", "λ‚΄μš©2")); boardList.add(new Board("제λͺ©3", "μž‘μ„±μž3", "λ‚΄μš©3")); return new ResponseEntity<>(boardList, HttpStatus.OK); } /** * κ²Œμ‹œκΈ€ 쑰회 * [GET] * /board * - response : board * @param model * @param boardNo * @return * @throws Exception */ @GetMapping(value="/{boardNo}") public ResponseEntity<Board> read(@PathVariable("boardNo") int boardNo) throws Exception { log.info("[GET] - /board/read"); Board board = new Board("제λͺ©1", "μž‘μ„±μž1", "λ‚΄μš©1"); return new ResponseEntity<>(board, HttpStatus.OK); } /** * κ²Œμ‹œκΈ€ μ“°κΈ° 처리 * [POST] * /board * - response : * βœ… μš”μ²­ 성곡 : 200 OK "SUCCESS" * ❌ μš”μ²­ μ‹€νŒ¨ : 400 Bad Request "FAIL" * @param board * @return * @throws Exception */ @PostMapping(value="") public ResponseEntity<String> insertPro(Board board) throws Exception { int result = new Random().nextInt(2); if( result == 0 ) { return new ResponseEntity<>("FAIL", HttpStatus.BAD_REQUEST); } return new ResponseEntity<>("SUCCESS", HttpStatus.OK); } /** * κ²Œμ‹œκΈ€ μˆ˜μ • 처리 * [PUT] * /board * - response : * βœ… μš”μ²­ 성곡 : 200 OK "SUCCESS" * ❌ μš”μ²­ μ‹€νŒ¨ : 400 Bad Request "FAIL" * @param board * @return * @throws Exception */ @PutMapping(value="") public ResponseEntity<String> updatePro(Board board) throws Exception { int result = new Random().nextInt(2); if( result == 0 ) { return new ResponseEntity<>("FAIL", HttpStatus.BAD_REQUEST); } return new ResponseEntity<>("SUCCESS", HttpStatus.OK); } /** * κ²Œμ‹œκΈ€ μ‚­μ œ 처리 * [DELETE] * /board * - response : * βœ… μš”μ²­ 성곡 : 200 OK "SUCCESS" * ❌ μš”μ²­ μ‹€νŒ¨ : 400 Bad Request "FAIL" * @param boardNo * @return * @throws Exception */ @DeleteMapping(value="") public ResponseEntity<String> deletePro(@RequestParam("boardNo") int boardNo) throws Exception { log.info("boardNo : " + boardNo); int result = new Random().nextInt(2); if( result == 0 ) { return new ResponseEntity<>("FAIL", HttpStatus.BAD_REQUEST); } return new ResponseEntity<>("SUCCESS", HttpStatus.OK); } }
Java
볡사

μ‹€ν–‰ κ²°κ³Ό

μš”μ²­ ν…ŒμŠ€νŠΈ

β€’
Thunder Client 둜 μš”μ²­ ν…ŒμŠ€νŠΈ
β€’
HTML form νƒœκ·Έλ‘œ μš”μ²­ ν…ŒμŠ€νŠΈ
β€’
β—¦
Body Form title, writer, content
β€’
β—¦
Body Form boardNo, title, writer, content

Thunder Client 둜 μš”μ²­ ν…ŒμŠ€νŠΈ

β€’
Body Form title, writer, content
β€’
Body Form boardNo, title, writer, content

Run Collection

HTML form νƒœκ·Έλ‘œ μš”μ²­ ν…ŒμŠ€νŠΈ

β€’
build.gradle
implementation 'org.springframework.boot:spring-boot-starter-thymeleaf'
Plain Text
볡사
build.gradle μˆ˜μ • ν›„, [ν”„λ‘œμ νŠΈ 우클릭] > [ν”„λ‘œμ νŠΈ λ‹€μ‹œ λΉŒλ“œ] ν•΄μ•Ό ν”„λ‘œμ νŠΈ λ‹€μ‹œ λΉŒλ“œ
β€’
index.html
<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>HTML form νƒœκ·Έλ‘œ μš”μ²­ ν…ŒμŠ€νŠΈ</title> </head> <body> <h1>HTML form νƒœκ·Έλ‘œ μš”μ²­ ν…ŒμŠ€νŠΈ</h1> <p> POST, PUT, DELETE λŠ” μ‹€μ œ DB 와 연결이 μ•ˆ λ˜μ–΄ 있고, <br> 랜덀으둜 SUCCESS, FAIL μ‘λ‹΅ν•©λ‹ˆλ‹€. </p> <hr> <ul> <li>GET : <a href="http://localhost:8080/board">http://localhost:8080/board</a></li> <li>GET : <a href="http://localhost:8080/board/10">http://localhost:8080/board/10</a></li> <li> POST : <a href="http://localhost:8080/board">http://localhost:8080/board</a> <ul> <li>Body ➑ Form ➑ title, writer, content</li> </ul> </li> <li> PUT : <a href="http://localhost:8080/board">http://localhost:8080/board</a> <ul> <li>Body ➑ Form ➑ boardNo, title, writer, content</li> </ul> </li> <li> DELETE : <a href="http://localhost:8080/board">http://localhost:8080/board/10</a> <ul> <li>Body ➑ Form ➑ boardNo</li> </ul> </li> </ul> <hr> <h2>- GET : http://localhost:8080/board</h2> <form action="/board" method="GET"> <input type="submit" value="μš”μ²­"> </form> <hr> <h2>- GET : http://localhost:8080/board/10</h2> <form action="/board/10" method="GET"> <input type="submit" value="μš”μ²­"> </form> <hr> <h2>- POST : http://localhost:8080/board</h2> <h3>- Body ➑ Form ➑ title, writer, content</h3> <form action="/board" method="POST"> <input type="text" name="title" placeholder="title" value="제λͺ©"> <br> <input type="text" name="writer" placeholder="writer" value="μž‘μ„±μž"> <br> <input type="text" name="content" placeholder="content" value="λ‚΄μš©"> <br> <input type="submit" value="μš”μ²­"> </form> <hr> <h2>- PUT : http://localhost:8080/board</h2> <h3>- Body ➑ Form ➑ boardNo, title, writer, content</h3> <!-- form νƒœκ·Έμ—μ„œλŠ” method: GET,POST 만 지원됨 --> <form action="/board" method="POST" id="form-put"> <input type="text" name="boardNo" placeholder="boardNo" value="10"> <br> <input type="text" name="title" placeholder="title" value="제λͺ©"> <br> <input type="text" name="writer" placeholder="writer" value="μž‘μ„±μž"> <br> <input type="text" name="content" placeholder="content" value="λ‚΄μš©"> <br> <input type="button" value="μš”μ²­" onclick="update()"> </form> <hr> <h2>- DELETE : http://localhost:8080/board</h2> <h3>- Body ➑ Form ➑ boardNo</h3> <!-- form νƒœκ·Έμ—μ„œλŠ” method: GET,POST 만 지원됨 --> <form action="/board" method="POST" id="form-delete"> <input type="text" name="boardNo" placeholder="boardNo" value="10"> <br> <input type="button" value="μš”μ²­" onclick="remove()"> </form> <hr> <script> // κ²Œμ‹œκΈ€ μˆ˜μ • μš”μ²­ - JSON function update() { let request = new XMLHttpRequest() // μž…λ ₯ 정보 let form = document.getElementById('form-put') let boardNo = form.boardNo.value let title = form.title.value let writer = form.writer.value let content = form.content.value // JSON let data = { 'boardNo' : boardNo, 'title' : title, 'writer' : writer, 'content' : content } // 응닡 확인 request.onreadystatechange = function() { // μš”μ²­ 성곡 if( request.readyState == request.DONE && request.status == 200 ) { let response = request.responseText alert(response) } // μš”μ²­ μ‹€νŒ¨ if( request.readyState == request.DONE && request.status == 400 ) { let response = request.responseText alert(response) } // μ—λŸ¬ λ°œμƒ if( request.readyState == request.DONE && request.status == 500 ) { alert('μ„œλ²„μΈ‘ μ—λŸ¬ λ°œμƒ') } } // μš”μ²­ μ„€μ • let url = 'http://localhost:8080/board' request.open("PUT", url, true) request.setRequestHeader("Content-Type", "application/json") // JSON.stringify() : JavaScript 의 객체λ₯Ό JSON λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•˜λŠ” λ©”μ†Œλ“œ request.send( JSON.stringify(data) ) } // κ²Œμ‹œκΈ€ μ‚­μ œ μš”μ²­ - JSON function remove() { let request = new XMLHttpRequest() // μž…λ ₯ 정보 let form = document.getElementById('form-put') let boardNo = form.boardNo.value // JSON let data = { 'boardNo' : boardNo, } // 응닡 확인 request.onreadystatechange = function() { // μš”μ²­ 성곡 if( request.readyState == request.DONE && request.status == 200 ) { let response = request.responseText alert(response) } // μš”μ²­ μ‹€νŒ¨ if( request.readyState == request.DONE && request.status == 400 ) { let response = request.responseText alert(response) } // μ—λŸ¬ λ°œμƒ if( request.readyState == request.DONE && request.status == 500 ) { alert('μ„œλ²„μΈ‘ μ—λŸ¬ λ°œμƒ') } } // μš”μ²­ μ„€μ • let url = 'http://localhost:8080/board/' + boardNo request.open("DELETE", url, true) // JSON.stringify() : JavaScript 의 객체λ₯Ό JSON λ¬Έμžμ—΄λ‘œ λ³€ν™˜ν•˜λŠ” λ©”μ†Œλ“œ request.send() } </script> </body> </html>
HTML
볡사

Github (μ†ŒμŠ€μ½”λ“œ)