Spring - servlet-context.xml
2020. 9. 15. 15:22ㆍSpring
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
<?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.itwillbs.myweb" />
</beans:beans>
|
cs |
처음 Spring을 접하면 왜 controller에서 간단한 주소 만으로 이동이 가능한지 이해가 안 되는데
생성한 프로젝트 안의 이 XML 파일을 본다면 충분히 이해가 가능하다. 왜냐하면
<beans:property name="prefix" value="/WEB-INF/views/" /> 이 부분이 접두사, 즉 view에 보여줘야 할 파일들의 주소를 선언해줘서 찾아가게 하고 <beans:property name="suffix" value=".jsp" />
이 태그가 접미사 , 즉 파일의 확장자를 뜻하기 때문에 controller에서는 간단한 파일 이름만으로 포워딩이 가능한 방식이다. 이해가 안 된다면 xml파일들을 찾아가며 Spring의 흐름을 이해해 보도록 하자.
'Spring' 카테고리의 다른 글
Spring - Maven (0) | 2020.09.18 |
---|---|
Spring - Connection (0) | 2020.09.18 |
Spring - jstl(JSP Standard Tag Library) (0) | 2020.09.18 |
Spring - 출력문, DI(Dependecy Injection) (0) | 2020.09.15 |