Spring加载properties文件的两种方式

一:

  1. <context:property-placeholder location="classpath:conn.properties"/>  
  2.   
  3.   
  4.  <bean id="dataSource" class="${dataSource}">   
  5.     <property name="driverClass" value="${driverClass}" />  
  6.     <property name="jdbcUrl" value="${jdbcUrl}" />  
  7.     <property name="user" value="${user}" />  
  8.     <property name="password" value="${password}" />  
  9.  bean>  

二:

  1. <bean class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">  
  2.     <property name="locations">   
  3.         <array>  
  4.             <value>classpath:conn.propertiesvalue>  
  5.         array>  
  6.     property>  
  7. bean>  





springmvc
org.springframework.web.servlet.DispatcherServlet


contextConfigLocation
/WEB-INF/springmvc.xml



springmvc
*.htm





contextConfigLocation
/WEB-INF/spring.xml





你可能感兴趣的:(spring,mvc,java)