2019.07.26
1. 브라우저 특정 URL 요청을 DispatcherServlet이 받음
2. DispatcherServlet이 URI(/ksmartView)을 보고 controller 식별하기 위해 핸들러 매핑과 통신
3. 핸들러 매핑은 요청을 처리하는 특정 핸들러 메서드 반환 (MainController 특정 메서드)
4. DispatcherServlet은 특정 핸들러 메서드 호출 (public String 특정메서드 (Model model) 호출)
5. 핸들러 메서드는 모델과 뷰를 반환 (public String 특정메서드 (Model model) {return "view"})
6. DispatcherServlet 논리적 뷰 "view" 결정하는 뷰 리졸버를 찾아 호출
7. 뷰 리졸버는 논리적 뷰 이름을 물리적 뷰 이름에 매핑하는 로직 실행 (/template/view.html으로 변환)
8. DispatcherServlet은 뷰 실행 -> 뷰에서 model 객체 사용할 수 있게 함
9. 뷰는 DispatcherServlet으로 보내질 내용을 반환
10. DispatcherServlet은 응답을 다시 브라우저로 보냄
Hellow World 호출
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
import org.springframework.stereotype.Controller;
@Controller
public class MainController {
@GetMapping("/ksmartView")
public String view(Model model) {
model.addAttribute("test", "Hello World");
return "view";
}
}
|
1
2
3
4
5
6
7
8
9
10
11
12
|
<!-- view.html -->
<!DOCTYPE html>
<head>
<meta charset="EUC-KR">
<title> springMVC </title>
</head>
<body>
<h1 th:text="${test}"></h1>
</body>
</html>
|
'교육 > Spring Boot' 카테고리의 다른 글
#59 Spring Boot log4j 설정 (0) | 2019.08.05 |
---|---|
#58 Spring Boot MyBatis trim (0) | 2019.08.05 |
#57 Spring Boot Mybatis SELECT 조건, MyBatis LIKE 사용 (0) | 2019.08.05 |
#54 Spring Boot MyBatis로 MySQL DB 연동 (0) | 2019.08.02 |
#52 Spring 기초 (0) | 2019.08.01 |