본문 바로가기
괴발개발/java

Srping web.xml 해석

by 맛길만걷자 2024. 8. 3.
728x90
반응형

<?xml version="1.0" encoding="UTF-8"?>
<web-app version="4.0" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://JAVA.sun.com/xml/ns/javaee https://java.sun.com/xml/ns/javaee/web-app_4_0.xsd">

<!-- web.xml(배포 서술자) 서버가 켜질 때 (배포가 시작될 때) 가장 먼저 읽어들이는 설정 파일 -->


<!-- root-context.xml
서버가 켜질때 web.xml이 가장 먼저 읽어들이는 설정 파일
프로젝트 전반적으로 사용도리 설정, 객체(Bean)를 생성하는 용도의 파일
  -->

<!-- The definition of the Root Spring Container shared by all Servlets 
and Filters -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/root-context.xml</param-value>
</context-param>

<!-- Creates the Spring Container shared by all Servlets and Filters -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener
</listener-class>
</listener>

<!-- Processes application requests -->

<!-- DispatcherServlet(spring에서 제공) 객체 생성 시
 servlet-context.xml 파일을 이용해서 만든다.
 
  -->
<servlet>
<servlet-name>appServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet
</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:spring/appServlet/servlet-context.xml
</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>

<servlet-mapping>
<servlet-name>appServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>

<!-- 한글 깨짐 방지를 위한 Filter 추가 -->
<!-- 별도의 filter 클래스를 만들지 않고 스프링에서 제공하는 filter를 사용 -->
<filter>
<filter-name>encodingFilter</filter-name>
<filter-class>org.springframework.web.filter.CharacterEncodingFilter
</filter-class>
<init-param>
<param-name>encoding</param-name>
<param-value>UTF-8</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

</web-app>

728x90
반응형

'괴발개발 > java' 카테고리의 다른 글

스프링 스케쥴러  (0) 2024.08.23
Spring servlet-context_xml 해석 및 root-context역할  (0) 2024.08.03
spring 용어 정리 및 mvc 흐름  (0) 2024.08.02
Spring 파라미터 전달방법  (0) 2024.08.02
Spring Framework  (0) 2024.08.01