servlet-context.xml, root-context.xml, web.xml에 대한 차이점에 대해 정리해봅니다.
우선, xml 파일은 모두 객체(Bean)를 정의합니다.
1. servlet-contex.xml
servlet에서 보듯이 요청과 관련된 객체를 정의합니다.
url과 관련된 controller나, @(어노테이션), ViewResolver, Interceptor, MultipartResolver 등의 설정을 해줍니다.
초기 파일을 보시면
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
위와 같은 주석이 있는데,,
DispatcherServlet과 관련된 설정을 해야함을 알 수 있습니다.
2. root-contex.xml
servlet-context.xml 과는 반대로 view와 관련되지 않은 객체를 정의합니다.
따라서 Service, Repository(DAO), DB등 비즈니스 로직과 관련된 설정을 해줍니다.
아래 사진을 참고하시면 좋을 것 같습니다.
(출처: https://docs.spring.io/spring/docs/current/spring-framework-reference/web.html#mvc)
3. web.xml
설정을 위한 설정파일입니다.
즉, 최초로 WAS가 최초로 구동될 때, 각종 설정을 정의해줍니다.
여러 xml파일을 인식하도록 각 파일을 가리켜 줍니다.
'Dev- > Spring' 카테고리의 다른 글
스프링 여러가지 의존성 주입(DI) 방법 (0) | 2019.03.16 |
---|---|
스프링 핸들러 매핑(Handler Mapping)이란 (0) | 2019.03.13 |
Spring Security 관련 에러 해결법 (0) | 2018.08.15 |
아주 기초적인 Spring Security 사용법 (1) (0) | 2018.08.15 |
스프링 Filter 만들기 (0) | 2018.08.09 |