2007-07-25

加载Spring的 Web.xml配置

关键字: 加载Spring的 Web.xml配置
xml 代码
  1. <?xml version="1.0" encoding="UTF-8"?>  
  2. <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">  
  3.   <!-- log4j在spring中的配置 -->  
  4.   <!--然后加上这个Spring的Log4j侦听类,注意在JBOSS里面,不需要这个类,注释掉,不然会冲突,-->  
  5.     <listener>  
  6.         <listener-class>org.springframework.web.util.Log4jConfigListener</listener-class>  
  7.     </listener>  
  8.     <!--webAppRootKey 属性为webApp.root 代表webApp的根目录,这样就能在properties文件中定义-->  
  9.     <!-- 这里的webApp是http://localhost:8080/webApp/ -->  
  10.     <context-param>  
  11.         <param-name>webAppRootKey</param-name>  
  12.         <param-value>webApp.root</param-value>  
  13.     </context-param>  
  14.     <!--log4jConfigLocation 属性代表log4j.properties文件的地址-->     
  15.     <!-- log4j.appender.file.File=${webApp.root}/WEB-INF/logs/subject.log  -->  
  16.     <context-param>  
  17.         <param-name>log4jConfigLocation</param-name>  
  18.         <param-value>/WEB-INF/log4j.properties</param-value>  
  19.     </context-param>     
  20.  <!--  -->  
  21.   <listener>  
  22.   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>  
  23.  </listener>  
  24.  <context-param>  
  25.   <param-name>contextConfigLocation</param-name>  
  26.   <param-value>/WEB-INF/spring-config.xml</param-value>  
  27.  </context-param>    
  28.        
  29.   <!-- servlet映射-->     
  30.   <servlet>  
  31.     <description>This is the description of my J2EE component</description>  
  32.     <display-name>This is the display name of my J2EE component</display-name>  
  33.     <servlet-name>InitParameter</servlet-name>  
  34.     <servlet-class>com.gridit.qe.servlet.InitParameter</servlet-class>  
  35.   </servlet>  
  36.   <servlet-mapping>  
  37.     <servlet-name>InitParameter</servlet-name>  
  38.     <url-pattern>/servlet/InitParameter</url-pattern>  
  39.   </servlet-mapping>    
  40.       
  41. <!-- 指定JNDI JDBC DataSource -->  
  42.   <resource-ref>  
  43.     <description>JNDI JDBC DataSource</description>  
  44.     <res-ref-name>jdbc/jndidemo</res-ref-name>  
  45.     <res-type>javax.sql.DataSource</res-type>  
  46.     <res-auth>Container</res-auth>  
  47.   </resource-ref>     
  48.      
  49. </web-app>  
评论
xingzhejh 2008-05-21
引用
[img][/img][url][/url][flash=200,200][/flash]
发表评论

您还没有登录,请登录后发表评论

seawavecau
搜索本博客
最近加入圈子
存档
最新评论