반응형
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파일을 인식하도록 각 파일을 가리켜 줍니다.
반응형
'BACK' 카테고리의 다른 글
| <![CDATA[ ]]> 사용이유? (0) | 2023.11.03 |
|---|---|
| Linux 단축 명령어 설정 (Alias) (0) | 2023.10.27 |
| spring AOP (0) | 2021.03.02 |
| 비밀번호 암호화 (0) | 2021.02.15 |
| 자주 사용하는 spring annotation 정리 (0) | 2021.02.08 |