关于@Value(“${xxx}”)取不到值的原因,首先保证spring-mvc.xml里面的配置正确
<bean id="configProperties"
class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list>
<value>classpath:view.properties</value>
<value>classpath:configfilename.properties</value>
</list>
</property>
</bean>
<bean id="propertyConfigurer"
class="org.springframework.beans.factory.config.PreferencesPlaceholderConfigurer">
<property name="properties" ref="configProperties" />
</bean>
以及applicationContent.xml的配置正确,以及web.xml的正确配置....................
在保证以上的配置的正确性之后,在加上
<context:property-placeholder location="classpath:配置文件的地址" ignore-unresolvable="true"/>
该配置,则可以获取到正确配置文件.properties文件的值