人生は、お天気いろいろ

日々の生活やプログラミング等に関するメモ・雑文を記載しています

SpringMVC dispatcher-servlet.xmlとapplicationContext.xmlの定義方法

個人用のメモ書き。

 

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" id="WebApp_ID" version="3.0">
  <display-name>SpringMVC</display-name>

  <filter-mapping>
    <filter-name>encodingFilter</filter-name>
    <url-pattern/>
  </filter-mapping>
  <filter-mapping>
    <filter-name>cacheControlFilter</filter-name>
    <url-pattern/>
  </filter-mapping>
  <filter-mapping>
    <filter-name>loggingFilter</filter-name>
    <url-pattern/>
  </filter-mapping>

  <listener>
    <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
  </listener>

  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>/WEB-INF/spring/applicationContext.xml</param-value>
  </context-param>

  <servlet>
    <servlet-name>dispatcher</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <!--
     ContextLoaderListenerの読み込んだグローバルなコンテキストの子供して階層化される。
     そのため、子供のコンテキストは親にアクセス可能だが、その逆は不可能である。
    -->
    <init-param>
      <param-name>contextConfigLocation</param-name>
      <param-value>/WEB-INF/spring/dispatcher-servlet.xml</param-value>
    </init-param>
    <load-on-startup>1</load-on-startup>
  </servlet>

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

  <session-config>
    <session-timeout>30</session-timeout>
  </session-config>

  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>

</web-app>

 

以下、参考。

d.hatena.ne.jp