Rumah  >  Artikel  >  hujung hadapan web  >  web.xml的配置

web.xml的配置

php中世界最好的语言
php中世界最好的语言asal
2018-03-07 16:53:562058semak imbas

这次给大家带来web.xml的配置,web.xml配置注意事项有哪些,下面就是实战案例,一起来看一下。

<!DOCTYPE web-app PUBLIC
 "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN"
 "http://java.sun.com/dtd/web-app_2_3.dtd" ><web-app>
  <display-name>Archetype Created Web Application</display-name>
  <!-- 定位applicatioinContext.xml路径 -->
  <context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>classpath:applicationContext.xml</param-value>
  </context-param>
  <filter>
      <filter-name>springEncoding</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>
      <init-param>
          <param-name>forceEncoding</param-name>
          <param-value>true</param-value>
      </init-param>
  </filter>
  <filter>
    <filter-name>openSessionInView</filter-name>
    <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
    <init-param>
        <param-name>sessionFactoryBeanName</param-name>
        <param-value>sessionFactory</param-value>
    </init-param>
  </filter>
  <filter>
      <filter-name>sessionFilter</filter-name>
      <filter-class>com.troyforever.example.filter.SessionFilter</filter-class>
  </filter>
  <filter-mapping>
      <filter-name>springEncoding</filter-name>
      <url-pattern>/*</url-pattern>
  </filter-mapping>
  <filter-mapping>
    <filter-name>openSessionInView</filter-name>
    <url-pattern>/*</url-pattern>
  </filter-mapping>
    <filter-mapping>
      <filter-name>sessionFilter</filter-name>
      <url-pattern>/admin/*</url-pattern>
  </filter-mapping>  
  <!-- 加载applicationContext.xml配置文件 -->
    <listener>
     <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
    </listener>
   <servlet>
    <servlet-name>example</servlet-name>
    <servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
  </servlet>
  <servlet-mapping>
    <servlet-name>example</servlet-name>
    <url-pattern>/</url-pattern>
  </servlet-mapping>
  </web-app>

相信看了本文案例你已经掌握了方法,更多精彩请关注php中文网其它相关文章!

相关阅读:

Spring的MVC配置

Hibernate的映射文件详解

Atas ialah kandungan terperinci web.xml的配置. Untuk maklumat lanjut, sila ikut artikel berkaitan lain di laman web China PHP!

Kenyataan:
Kandungan artikel ini disumbangkan secara sukarela oleh netizen, dan hak cipta adalah milik pengarang asal. Laman web ini tidak memikul tanggungjawab undang-undang yang sepadan. Jika anda menemui sebarang kandungan yang disyaki plagiarisme atau pelanggaran, sila hubungi admin@php.cn
Artikel sebelumnya:Spring的MVC配置Artikel seterusnya:Spring的配置