개발/개발관련

[개발관련] 배포기술자 web.xml

mabb 2023. 6. 2. 10:27
반응형


<?xml version="1.0" encoding="UTF-8"?>
<!--위의 코드는 xml임을 알리는 부분 xml버전1.0 , UTF-8 명시 -->
<!--
Licensed to the Apache Software Foundation (ASF) under one or more
contributor license agreements. See the NOTICE file distributed with
this work for additional information regarding copyright ownership.
The ASF licenses this file to You under the Apache License, Version 2.0
(the "License"); you may not use this file except in compliance with
the License. You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
-->

<!--web.xml은 Deployment Descriptor(DD,배포서술자)라고도 한다. web.xml은 배포에 대한
환경설정을 담당한다. 웹 애플리케이션의 기본적인 설정을 위해 작성하는 파일이다. WEB-INF/web.xml 의 경로가 규격이다.
web.xml을 사용하는 이유
1.작성한 소스코드 수정없이 웹애플리케이션 커스터마이징이 가능하다.
2.소스코드없이 수정이 가능하다.
3.재 컴파일 하지 않고 서버의 자원을 변경할 수 있다.
4.접근제한, 보안, 오류페이지 및 초기화 값의 구성등을 설정할 수 있다.-->

<!--web-app태그는 web.xml의 가장 루트 엘리먼트-->
 http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" metadata-complete="true" version="3.0">
<!--display-name은 타이틀(제목)-->
<display-name>mabb</display-name>

<!--필터 선언 : utf-8 필터를 선언-->
<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>

<!--필터 적용: /* url패턴에 필터 적용 -->
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>

<!--세션 timeout 120분 / 쿠키 http only-->
<session-config>
<session-timeout>120</session-timeout>
<cookie-config>
<http-only>true</http-only>
</cookie-config>
</session-config>
<!--<filter>-->
<!--<filter-name>HTMLTagFilter</filter-name>-->
<!--<filter-class>egovframework.rte.ptl.mvc.filter.HTMLTagFilter</filter-class>-->
<!--</filter>-->
<!--<filter-mapping>-->
<!--<filter-name>HTMLTagFilter</filter-name>-->
<!--<url-pattern>*.do</url-pattern>-->
<!--</filter-mapping>-->

<!--ContextLoaderListener가 읽을 xml 설정-->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring/applicationContext*.xml</param-value>
</context-param>

<!--1.ContextLoaderListener 클래스는 스프링컨테이너가 web.xml파일을 읽어서 구동될 때 자동으로 생성된다.
클라이언트의 요청이 없어도 preLoding되는 객체. contextConfigLocation으로 설정한
applicationContext*.xml을 읽는다. 요청이 들어오기 전에 Bean을 셋팅(생성)해두는 역할이다.
이 때 생성하는 Bean객체가 Service, DAO 객체 등이다.
root-context.xml(applicationContext.xml)을 기반으로 root컨테이너 구동.
-->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- RequestContextListener라는 리스너도 있다. 컨트롤러 외에서 HttpServletRequest를 쓰기 위한용도? -->

<!--2.최초의 요청이 들어오면 스프링은 디스패처서블릿을 생성한다. 생성된 디스패처서블릿은 init-param으로 설정한
servlet-context.xml(applicationServlet.xml)을 읽고 설정된 Bean객체를 생성한다. 이 때 생성하는 Bean객체가
디스패처서블릿을 돕는 핸들러매퍼객체, 핸들러어댑터객체 등이다.-->
<!--디스패처서블릿 설정-->
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:config/spring/applicationServlet.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<!--action(디스패처서블릿)을 적용할 url패턴을 .do로 설정-->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>.do</url-pattern>
</servlet-mapping>

<!--서블릿보안/ 로그인 인증방식 설정 1)BASIC : HTTP표준 2)DIGEST:HTTP,J2EE 3)CLIENT-CERT:사용자인증서 4)FORM:사용자정의 로그인화면 -->
<login-config>
<auth-method>BASIC</auth-method>
</login-config>

<!--'/'루트 요청 시 welcome-file로드 -->
<welcome-file-list>
<welcome-file>/webapps/mabb/main/mabbLoginCheck.jsp</welcome-file>
</welcome-file-list>

<!--url패턴이 .jsp인 경우 HeaderPage.jsp를 맨 앞에 include, FooterPage.jsp를 맨 뒤에 include
prelude는 전주곡, coda는 마무리곡 이라는 의미 (왜 코딩에 이런 용어를?!)-->
<jsp-config>
<jsp-property-group>
<url-pattern>.jsp</url-pattern>
<include-prelude>/webapps/include/HeaderPage.jsp</include-prelude>
<include-coda>/webapps/include/FooterPage.jsp</include-coda>
</jsp-property-group>
</jsp-config>

<!--각각의 예외 발생 시 해당하는 location의 에러페이지로 이동-->
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>400</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>401</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>403</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>501</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>502</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/webapps/mabb/excp/mabbExcp03.jsp</location>
</error-page>

<!--매핑할 서블릿과 서블릿에 매핑되는 url을 설정한다.
파일 업로드, 파일 다운로드, 엑셀 익스포트 등 부가적인 기능들을 담당하는 서블릿과 그에 매핑되는 url을 설정한다.-->
<servlet>
<servlet-name>FileDownload</servlet-name>
<servlet-class>mabb.core.servlet.FileDownloadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FileDownload</servlet-name>
<url-pattern>/servlet/FileDownloadServlet</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>FileUpload</servlet-name>
<servlet-class>mabb.core.servlet.FileUploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>FileUpload</servlet-name>
<url-pattern>/servlet/FileUploadServlet</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>ExcelExport</servlet-name>
<servlet-class>mabb.core.servlet.ExcelExportServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>ExcelExport</servlet-name>
<url-pattern>/servlet/ExcelExportServlet</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>HttpInterface</servlet-name>
<servlet-class>mabb.base.interfaces.HttpInterface</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>HttpInterface</servlet-name>
<url-pattern>/interfaces/HttpInterface</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>DHXGridExcelDownload</servlet-name>
<servlet-class>mabb.core.servlet.dhtmlx.ExcelGenerator</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>DHXGridExcelDownload</servlet-name>
<url-pattern>/servlet/DHXGridExcelDownload</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>BoardImageUploadServlet</servlet-name>
<servlet-class>mabb.core.servlet.BoardImageUploadServlet</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>BoardImageUploadServlet</servlet-name>
<url-pattern>/servlet/BoardImageUploadServlet</url-pattern>
</servlet-mapping>
</web-app>

반응형