首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 网站开发 > Web前端 >

web.xml 配备化

2012-09-14 
web.xml 配置化?xml version1.0 encodingUTF-8 ?web-app version2.5 xmlnshttp://java.sun.

web.xml 配置化
<?xml version="1.0" encoding="UTF-8" ?>
<web-app version="2.5" xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd">
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
/WEB-INF/spring-config/applicationContext-*.xml
</param-value>
</context-param>
   <filter>
<filter-name>struts2</filter-name>
<filter-class>
org.apache.struts2.dispatcher.FilterDispatcher
</filter-class>
<!--
<init-param>  
<param-name>config</param-name>  
把struts2的配置文件放到WEB-INF下面
<param-value>WEB-INF/struts2.0/struts.xml</param-value>  
</init-param>
-->
</filter>
<filter-mapping>
<filter-name>struts2</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>



<!--以下是由Spring提供的filter来解决Struts乱码问题 -->
<filter>
<filter-name>encoding</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>

<filter-mapping>
<filter-name>encoding</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 解决乱码 -->

<!-- 使用Spring解决Hiberante因session关闭导致的延迟例外问题 -->
<filter>
<filter-name>OpenSessionInViewFilter</filter-name>
<filter-class>
org.springframework.orm.hibernate3.support.OpenSessionInViewFilter
</filter-class>
</filter>

<filter-mapping>
<filter-name>OpenSessionInViewFilter</filter-name>
<url-pattern>/*</url-pattern>
</filter-mapping>
<!-- 解决延迟加载例外问题 -->


<!-- Spring的监听器,以启动spring的root webApplicationContext,来简单地代理ContextLoader -->

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

<listener>
<listener-class>
cn.com.kxrj.servlet.StartListener
</listener-class>
</listener>

<welcome-file-list>
<welcome-file>admin/login.jsp</welcome-file>
</welcome-file-list>

</web-app>

热点排行