Record
servlet-context.xml 본문
- Project를 처음 만들었을 때의 servlet-context.xml
<?xml version="1.0" encoding="UTF-8"?>
<beans:beans xmlns="http://www.springframework.org/schema/mvc"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:beans="http://www.springframework.org/schema/beans"
xmlns:context="http://www.springframework.org/schema/context"
xsi:schemaLocation="http://www.springframework.org/schema/mvc https://www.springframework.org/schema/mvc/spring-mvc.xsd
http://www.springframework.org/schema/beans https://www.springframework.org/schema/beans/spring-beans.xsd
http://www.springframework.org/schema/context https://www.springframework.org/schema/context/spring-context.xsd">
<!-- DispatcherServlet Context: defines this servlet's request-processing infrastructure -->
<!-- Enables the Spring MVC @Controller programming model -->
<annotation-driven />
<!-- Handles HTTP GET requests for /resources/** by efficiently serving up static resources in the ${webappRoot}/resources directory -->
<resources mapping="/resources/**" location="/resources/" />
<!-- Resolves views selected for rendering by @Controllers to .jsp resources in the /WEB-INF/views directory -->
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<beans:property name="prefix" value="/WEB-INF/views/" />
<beans:property name="suffix" value=".jsp" />
</beans:bean>
<context:component-scan base-package="com.test.noticejavaversion" />
</beans:beans>
servlet-context.xml 파일은 DispatcherServlet 기반 설정을 기록하는 파일로, URL(Request)과 관련된 Controller, Annotation, ViewResolver, Interceptor, MultipartResolver 등의 설정을 하는 파일이다.
<annotation-driven /> 태그는 package 내부의 class 중에서 Controller 어노테이션을 가지고 있는 class들을 Controller로 로딩하도록 하는 태그이다.
<resources ~ /> 태그는 static resources(이미지, 사운드, 동영상, JS, CSS 등)의 경로를 설정해주는 태그이다.
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> 태그는 Controller의 method에서 반환하는 문자열 앞 뒤에 붙여줄 경로 정보를 설정하는 태그이다.
<context:component-scan base-package="~" /> 태그는 스캔할 Bean 들이 모여있는 package를 지정하는 태그이다.
'JAVA > Spring' 카테고리의 다른 글
Architecture of Spring MVC Model (0) | 2022.04.18 |
---|---|
HTTP 전송 정보 (0) | 2022.04.18 |
root-context.xml (0) | 2022.04.18 |
web.xml (0) | 2022.04.18 |
Comments