目的
- 对于一些修改的常量保存到配置文件中,以后修改只需修改配置文件,无需改动后台代码
步骤
- springmvc-servlet.xml配置文件
<bean id="configProperties" class="org.springframework.beans.factory.config.PropertyPlaceholderConfigurer">
<property name="locations">
<list>
<value>classpath:configure.properties</value>
</list>
</property>
<property name="fileEncoding" value="UTF-8"></property>
</bean>
- configure.properties配置文件
domain=http://jbx.xinjianbao.net
- controller读取
@Value("${domain}")
private String domain;
- 结束