Spring gets the value method of properties
Configuring in Spring.xml
Oddly enough, the Context-param loaded spring.xml cannot use ${xxx}
Must be handed over to Dispatcherservlet management springmvc.xml to use?
To give Springmvc dispatcherservlet to scan, instead of Spring listener Contextloaderlistener to scan, it can be more convenient to use "${xxx" to inject.
1. Use $ to get properties
@Value ("${user.name}")
Private String UserName;
<!--方法1-->
<location= "Classpath*:info/info.properties"/>
<!--方法2-->
<Beanclass= "Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer"> < Propertyname= "Order"value= "1" /> < Propertyname= "Locations"> <List> <value>Classpath:info/info.properties</value> </List> </ Property></Bean>
2. Use #获取属性
@Value ("#{user.name}")
Private String UserName;
<BeanID= "prop"class= "Org.springframework.beans.factory.config.PropertiesFactoryBean"> < Propertyname= "Locations"> <Array> <value>Classpath:configure.properties</value> </Array> </ Property> </Bean>
Spring is set in properties file by @value, and differs from @value # and $