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

加载Spring的 Web.xml配置

2008-08-23 10:55 435 查看
想做一个小项目,在网上收集了一些资料

----------

<?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" xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd" version="2.4">

<!-- log4j在spring中的配置 -->

<!--然后加上这个Spring的Log4j侦听类,注意在JBOSS里面,不需要这个类,注释掉,不然会冲突,-->

<listener>

<listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>

</listener>

<!--webAppRootKey 属性为webApp.root 代表webApp的根目录,这样就能在properties文件中定义-->

<!-- 这里的webApp是http://localhost:8080/webApp/ -->

<context-param>

<param-name>webAppRootKey</param-name>

<param-value>webApp.root</param-value>

</context-param>

<!--log4jConfigLocation 属性代表log4j.properties文件的地址-->

<!-- log4j.appender.file.File=${webApp.root}/WEB-INF/logs/subject.log -->

<context-param>

<param-name>log4jConfigLocation</param-name>

<param-value>/WEB-INF/log4j.properties</param-value>

</context-param>

<!-- -->

<listener>

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

</listener>

<context-param>

<param-name>contextConfigLocation</param-name>

<param-value>/WEB-INF/spring-config.xml</param-value>

</context-param>

<!-- 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>InitParameter</servlet-name>

<servlet-class>com.gridit.qe.servlet.InitParameter</servlet-class>

</servlet>

<servlet-mapping>

<servlet-name>InitParameter</servlet-name>

<url-pattern>/servlet/InitParameter</url-pattern>

</servlet-mapping>

<!-- 指定JNDI JDBC DataSource -->

<resource-ref>

<description>JNDI JDBC DataSource</description>

<res-ref-name>jdbc/jndidemo</res-ref-name>

<res-type>javax.sql.DataSource</res-type>

<res-auth>Container</res-auth>

</resource-ref>

</web-app>
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: