스프링 MVC란 ? - MVC (Model - View - Controller) 디자인 패턴을 말합니다.
서버에서 HTML을 내려주는 경우
HTTP 메시지 이해
- Client 와 Server 간 Request, Response 는 HTTP 메시지 규약을 따름
- HTTP 메시지는 웹 서비스 개발자(백엔드, 프론트 개발자)에게 매우 중요한 내용!!
-메시지 구조
1. 시작줄 (start line)
-Response 에선 '상태줄 (status line)' 이라고 부름
2. 헤더 (headers)
3. 본문 (body)
-Request 메시지
1. 시작줄: API 요청 내용
2. 헤더
Content type: application/x-www-form-urlencoded
- AJAX 요청
Content type: application/json
3. 본문
-Response 메시지
1. 상태줄: API 요청 결과 (상태 코드, 상태 텍스트)
2. 헤더
Content type: text/html
3. Response 본문 내용이 JSON 인 경우
Content type: application/json
Location: http://localhost:8080/hello.html
<!DOCTYPE html>
<html>
<head><title>By @ResponseBody</title></head>
<body>Hello, Spring 정적 웹 페이지!!</body>
</html>
- JSON
{
"name":"홍길동",
"age": 20
}
Controller 와 HTTP Response 메시지
Controller 와 HTTP Request 메시지
스프링 MVC 동작원리