1.在applicationContext.xml文件下配置:
<bean id="appProperty"
class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<array>
<value>classpath:app.properties</value>
</array>
</property>
</bean>
2.在需要注入属性处使用@Value注解:
比如:@Value(“${jdbc.username}”)
public String username;
3.web.xml文件中的<context-param></context-param>
会被转化为键值对存在servletContext中,这个过程是在所有servlet启动之前执行的。