web配置详解
来源:互联网 发布:python 最小值 索引 编辑:程序博客网 时间:2024/05/16 06:43
<?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" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>demo</display-name>
<!-- Spring ApplicationContext配置文件的路径,可使用通配符,用于后面的Spring Context Loader -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext.xml //这里表示,我们的web容器需要加载这个文件的同时,也需要加载这个文件中包含的classpath中的.xml文件
classpath*:applicationContext-*.xml
</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name> //这里定义了我们的环境为开发环境
<param-value>development</param-value>
</context-param>
<!--Spring ApplicationContext 载入 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Filter 定义 -->
<!-- Character Encoding 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>
<init-param>
<param-name>forceEncoding</param-name> //强制性对之前的编码进行转换为UTF-8
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Open Entity Manager in View filter -->
<filter>
<filter-name>openEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>//Hibernate中使用到了懒加载,会造成当controller层和model层数据返回给view层时,造成session的关闭,这样view层出现数据访问异常。
</filter>
<filter-mapping>
<filter-name>openEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Security -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring MVC Servlet -->
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 如果没有定义的话,默认在/WEB-INF/springServlet.xml文件中定义 -->
<param-value>/WEB-INF/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 支持RESTful -->
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<servlet-name>springServlet</servlet-name>
</filter-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<!-- 根据异常类声明错误 -->
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/error/500.jsp</location>
</error-page>
<!-- 根据HTTP状态码声明错误 -->
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/error/500.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/error/404.jsp</location>
</error-page>
</web-app>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
version="2.5">
<display-name>demo</display-name>
<!-- Spring ApplicationContext配置文件的路径,可使用通配符,用于后面的Spring Context Loader -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath*:applicationContext.xml //这里表示,我们的web容器需要加载这个文件的同时,也需要加载这个文件中包含的classpath中的.xml文件
classpath*:applicationContext-*.xml
</param-value>
</context-param>
<context-param>
<param-name>spring.profiles.default</param-name> //这里定义了我们的环境为开发环境
<param-value>development</param-value>
</context-param>
<!--Spring ApplicationContext 载入 -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<!-- Filter 定义 -->
<!-- Character Encoding 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>
<init-param>
<param-name>forceEncoding</param-name> //强制性对之前的编码进行转换为UTF-8
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Open Entity Manager in View filter -->
<filter>
<filter-name>openEntityManagerInViewFilter</filter-name>
<filter-class>org.springframework.orm.jpa.support.OpenEntityManagerInViewFilter</filter-class>//Hibernate中使用到了懒加载,会造成当controller层和model层数据返回给view层时,造成session的关闭,这样view层出现数据访问异常。
</filter>
<filter-mapping>
<filter-name>openEntityManagerInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Security -->
<filter>
<filter-name>shiroFilter</filter-name>
<filter-class>org.springframework.web.filter.DelegatingFilterProxy</filter-class>
<init-param>
<param-name>targetFilterLifecycle</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>shiroFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- Spring MVC Servlet -->
<servlet>
<servlet-name>springServlet</servlet-name>
<servlet-class>org.springframework.web.servlet.DispatcherServlet</servlet-class>
<init-param>
<param-name>contextConfigLocation</param-name>
<!-- 如果没有定义的话,默认在/WEB-INF/springServlet.xml文件中定义 -->
<param-value>/WEB-INF/spring-mvc.xml</param-value>
</init-param>
<load-on-startup>1</load-on-startup>
</servlet>
<servlet-mapping>
<servlet-name>springServlet</servlet-name>
<url-pattern>/</url-pattern>
</servlet-mapping>
<!-- 支持RESTful -->
<filter>
<filter-name>httpMethodFilter</filter-name>
<filter-class>org.springframework.web.filter.HiddenHttpMethodFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>httpMethodFilter</filter-name>
<servlet-name>springServlet</servlet-name>
</filter-mapping>
<session-config>
<session-timeout>120</session-timeout>
</session-config>
<!-- 根据异常类声明错误 -->
<error-page>
<exception-type>java.lang.Throwable</exception-type>
<location>/WEB-INF/views/error/500.jsp</location>
</error-page>
<!-- 根据HTTP状态码声明错误 -->
<error-page>
<error-code>500</error-code>
<location>/WEB-INF/views/error/500.jsp</location>
</error-page>
<error-page>
<error-code>404</error-code>
<location>/WEB-INF/views/error/404.jsp</location>
</error-page>
</web-app>
0 0
- Web.XML 配置详解
- Web.XML 配置详解
- web.xml配置详解
- web.xml配置详解
- Web.config配置详解
- Web.config配置详解
- web.xml配置详解
- Web.XML 配置详解
- Web.config配置详解
- Web.config配置详解
- Web.XML 配置详解
- web.config配置详解
- Web.config配置详解
- Web.xml配置详解
- web.xml配置详解
- Web.config配置详解
- web.config配置详解
- web.xml 配置详解
- CAD控件:易语言使用控件二次开发入门
- 为关联容器编写插入迭代器
- [leetcode-148]Sort List(c)
- CYPEESS USB3.0程序解读之---GPIO
- Ajax异步请求阻塞情况的解决办法
- web配置详解
- Spring整合Hibernate,不用HibernateDaoSupport与HibernateTemplate而用Hibernate自己的api分析说明
- Knockout应用开发指南 第二章:监控属性(Observables)
- org.hibernate.hql.ast.QuerySyntaxException: is not mapped
- CYPEESS USB3.0程序解读之---同步FIFO(slaveFifoSync)
- UINavigationController官方文档学习笔记
- JavaScript中的this关键字
- 复杂链表的复制
- js 计算字符串长度 中英文