본문 바로가기
Programming/Spring

[Spring] MVC 구조

 

 

 

 

 


Spring Web MVC 추가 필요
Spring Context, Spring Core는 기본적으로 필요

■ Spring Life Cycle

HandlerMapping :

요청을 어떤 Controller로 매핑/@RequestMapping

Controller :

서비스를 실행, 서비스가 DAO 호출, DB 연동/ 다시 결과 전달을 위해 결과를 Controller로 전달 -> 즉 백엔드로 전달/@Controller

ModelAndView:

model이란 결과 값 / View는 여러개(jsp, html 등..)(어떤 뷰로 가야하나?)

ViewResolver :

(View 정보를 받아서) 어떤 view로 가야하는지 servlet에 알려줌

View :

servlet이 Model 객체를 전달하고 최종적으로 사용자에게 보여짐



--> Springbean 설정이 필요하다.
--> 하지만 <context-componentscan을 사용해 어노테이션으로 가능
--> 즉 ApplicationContext 필요하지만, Web에서는 WebApplicationContext로 불림




■ WebApplicationContext

■ spring mvc 생성

projectfacets
compiler
library(build path)

pom.xml - java11, 5.5.24로 변경

  • spring은 주소를 감춘다...

@modelAttribute

1) 인수 : 뷰쪽으로 전달되는 객체의 별칭 만들기
2) 메소드 : 현재 컨트롤러를 실행하는 모든 요청들이 공유해서 사용한 정보를 뷰에 전달


사진 출처: https://yongku.tistory.com/entry/%EC%8A%A4%ED%94%84%EB%A7%81Spring-MVCModel-View-Controller-%ED%8C%A8%ED%84%B4
https://docs.spring.io/spring-framework/docs/current/reference/html/web.html

'Programming > Spring' 카테고리의 다른 글

[Spring] Spring을 시작하기 위한 환경 설정(Chapter 1)  (0) 2024.02.03
[Spring] Transaction  (0) 2023.06.16
[Spring] Annotation, lombok 활용  (0) 2023.06.16
[Spring] 두번째 개념 정리  (0) 2023.06.16
[Spring] 시작  (0) 2023.06.16