코배스 Part2 : chapter 05
2021. 3. 26. 12:46ㆍSpring/Spring[Info]
반응형
📕 프로젝트 구동 순서
- web.xml : Tomcat 구동과 관련된 설정
- root-context.xml, servlet-context.xml : 스프링과 관련된 설정
1. Web.xml
프로젝트 구동은 Web.xml에서 시작합니다.
- <context-param>에는 root-context.xml의 경로가 설정
- <listener>에는 스프링 MVC의 ContextLoaderListener가 등록되어 있다.
- ContextLoaderListener는 해당 웹 애플리케이션 구동 시 같이 동작하여 root-context.xml의 처리에 따라서 Bean 설정이 동작합니다.
2. DispatcherServlet
root-context.xml이 처리된 후에는 스프링에 DispatcherServlet이 실행됩니다.
- DispatcherServlet 클래스는 스프링 MVC의 구조에서 가장 핵심적인 역할입니다.
- 내부적으로 웹 관련 처리의 준비작업을 진행, 이때 사용하는 파일이 servlet-context.xml
- XmlWebApplicationContext를 이용하여 servlet-context.xml을 로딩하고 해석함.
- 이 과정에서 등록된 객체(Bean)들은 기존에 만들어진 객체(Bean)들과 연동됨.
반응형