Home >Web Front-end >JS Tutorial >web.xml configuration

web.xml configuration

php中世界最好的语言
php中世界最好的语言Original
2018-03-07 16:53:562094browse

This time I will bring you the configuration of web.xml, web.xml configurationNotesWhat are the following are practical cases, let’s take a look.

<!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>

I believe you have mastered the method after reading the case in this article. For more exciting information, please pay attention to the php Chinese website Other related articles!

Related reading:

Spring’s MVC configuration

Hibernate’s mapping file detailed explanation

The above is the detailed content of web.xml configuration. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
Previous article:Spring MVC configurationNext article:Spring MVC configuration