加载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>
----------
<?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>
相关文章推荐
- web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序 研究
- 通过web.xml中的监听器加载spring配置文件
- 浅谈web.xml文件中加载Spring配置文件和SpringMVC配置文件
- spring通过在web.xml 中配置ContextLoaderListener 来加载co...
- Web.xml Webapp配置加载log4j和Spring
- Web.xml配置详解之context-param (加载spring的xml,然后初始化bean看的)
- Web.xml Webapp配置加载log4j和Spring
- web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序 研究
- 通过web.xml文件自动启动spring容器加载对应的配置文件
- spring的配置文件在web.xml中加载的方式
- web.xml文件中配置( listenr, filter,servlet, spring)的加载顺序 研究(转)
- web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序研究
- web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序
- web.xml加载多个spring配置文件
- Web项目中使用XML配置加载Spring及Spring MVC的组件
- web.xml 文件中一般包括 servlet, spring, filter, listenr的配置。那么他们是按照一个什么顺序加载呢?
- spring和struts2的web.Xml配置(spring的web加载)
- 加载spring在web.xml中相关配置
- spring的配置文件在web.xml中加载的方式
- web.xml文件中配置(servlet, spring, filter, listenr)的加载顺序 研究