您的位置:首页 > 编程语言 > Java开发

Spring, Log4j, 等各项在web.xml中配置

2013-09-24 18:49 260 查看
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
id="WebApp_1227143028044" version="2.4"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd"> 
<!-- 加载Spring服务 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>
classpath:/spring-dataSource.xml,
classpath:/spring-data.xml, classpath:/spring-server.xml,
/WEB-INF/applicationContext-*.xml
</param-value>
</context-param>

<!-- 加载log4j -->
<context-param>
<param-name>log4jConfigLocation</param-name>
<param-value>classpath:/log4j.properties</param-value>
</context-param>
<context-param>
<param-name>webAppRootKey</param-name>
<param-value>netctoss.root</param-value>
</context-param>

<!--处理请求编码格式-->
<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>
</filter>

<filter-mapping>
<filter-name>encodingFilter</filter-name>
<url-pattern>*.do</url-pattern>
</filter-mapping>

<!-- 自定义过滤器测试 -->
<filter>
<filter-name>adminFilter</filter-name>
<filter-class>com.ghrt.common.AdminFilter</filter-class>
</filter>

<filter-mapping>
<filter-name>adminFilter</filter-name>
<url-pattern>/admin/*</url-pattern>
</filter-mapping>

<!-- 监听Log4j -->
<listener>
<listener-class>
org.springframework.web.util.Log4jConfigListener
</listener-class>
</listener>

<!-- 监听Spring文件 -->
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>
org.springframework.web.context.ContextLoaderServlet
</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>

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

<!-- 配置dwr -->
<servlet>
<servlet-name>dwr-invoker</servlet-name>
<servlet-class>
org.directwebremoting.servlet.DwrServlet
</servlet-class>
<init-param>
<param-name>debug</param-name>
<param-value>true</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet>
<servlet-name>action</servlet-name>
<servlet-class>
org.apache.struts.action.ActionServlet
</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>3</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>3</param-value>
</init-param>
<load-on-startup>0</load-on-startup>
</servlet>

<servlet>
<description>
This is the description of my J2EE component
</description>
<display-name>
This is the display name of my J2EE component
</display-name>
<servlet-name>Image</servlet-name>
<servlet-class>com.ghrt.common.Image</servlet-class>
</servlet>

<!-- eWebEditor 配置 -->
<display-name>defaultroot</display-name>

<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<servlet-mapping>
<servlet-name>Image</servlet-name>
<url-pattern>/servlet/Image</url-pattern>
</servlet-mapping>

<servlet-mapping>
<servlet-name>dwr-invoker</servlet-name>
<url-pattern>/dwr/*</url-pattern>
</servlet-mapping>

<!-- 加载核心标签库 -->
<jsp-config>
<taglib>
<taglib-uri> http://www.java.sun.com/jsp/jstl/core </taglib-uri>
<taglib-location>/WEB-INF/jstl/c.tld</taglib-location>
</taglib>
</jsp-config>

<welcome-file-list>
<welcome-file>login.jsp</welcome-file>
</welcome-file-list>
<error-page>
<error-code>404</error-code>
<location>/404.jsp</location>
</error-page>
<error-page>
<error-code>503</error-code>
<location>/500.jsp</location>
</error-page>
<error-page>
<error-code>500</error-code>
<location>/500.jsp</location>
</error-page>
</web-app>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  log4j web.xml