본문 바로가기
Spring/설정파일

servlet-context.xml

by pms93 2022. 10. 26.
<?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 -->
	<!-- 
		* client의 요청이 들어오면 server(DispatcherServlet)는 viewResolver로 요청을 보내 하위의 설정된 property의 jsp를 찾아가 결과물을 반환한다.
		* ex) client의 home요청 -> DispatcherServlet -> ViewResolver -> ViewResolver는 요청의 접두사(prefix), 접미사(suffix)를 참조하여 경로를 생성(WEB-INF/views/home.jsp)하고
				이에 필요한 파일들이 배치된 설정 경로(base-package)를 함께 읽어들인 후 일치하는 jsp파일의 결과물을 client에게 반환한다.
	-->
	<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.ms.blog" />
	
	
	
</beans:beans>

'Spring > 설정파일' 카테고리의 다른 글

pom.xml  (0) 2022.10.26
web.xml  (0) 2022.10.26