在项目中,有些参数需要配置到属性文件xxx.properties中,这样做是为了维护方便,如果需要变动只需修改属性文件,不需要重新编译项目就可以了,非常方便。
而为了使用起来方便,可以通过将属性值注入到类的静态字段中(static),这样就可以用className.fieldName的方式来获取了。
1.servlet-context.xml
<!-- spring的属性加载器,加载properties文件中的属性 -->
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="location" value=