DevBoi

[Spring] 스프링의 동작방식 본문

Develop/[Spring]

[Spring] 스프링의 동작방식

HiSmith 2022. 3. 24. 17:34
반응형

1. 웹 애플리케이션이 실행되면 Tomcat에 의해 web.xml이 loading 된다.

2. web.xml에 등록되어있는 ContextLoaderListener가 생성이 된다.  (ServletContextListener 구현)
,ApplicationContext를 생성하는 역할을 수행한다.

3. 생성된 ContextLoaderListener는 root-context.xml 을 로딩한다.

4. root-context.xml에 등록되어있는 Spring Container가 구동된다. 이 때 개발자가 작성한 비즈니스 로직에 대한 부분과 DAO, VO 객체들이 생성된다.

5. 클라이언트에게서 웹 애플리케이션 요청이 온다.(web.xml에 등록한 url 패턴과 맞다면)

6. DispatcherServlet이 생성된다. DispatcherServlet은 FrontController역할을 수행한다.

7. DispatcherServlet은 요청된 URL을 HandlerMapping  객체에 넘기고 호출해야할 Controller 메소드 정보를 얻는다.

8. 전달 받은 컨트롤러 객체를 처리할 수 있는 HandlerAdapter에게 요청을 위임한다.

9. HandlerAdapeter 가 컨트롤러에게 요청을 보내고 처리하여 처리 결과를 ModelAndView로 변환하고 DispatcherSevlet에게 전달한다.

10. DispathcherServlet이 View Resolver에게 View의뢰를 하고, View를 response한다.

 

 

 

반응형

'Develop > [Spring]' 카테고리의 다른 글

[Spring] Spring 구동 과정  (0) 2022.03.24
[Spring] Spring 과 SpringBoot의 차이  (0) 2022.03.24
[Spring] Spring 의 정의 및 특징  (0) 2022.03.24
[Spring] @Configuration  (0) 2022.03.03
[Spring] 주요 어노테이션 총 정리  (0) 2022.03.03