2016-12-07 21 views
2

我的Spring Web模型 - 视图 - 控制器(MVC)框架中有这个类。 Spring Web模型 - 视图 - 控制器(MVC)框架的版本是3.2.8。在Spring Web MVC 3.2.8中使用maven读取一个属性key

在我applicationContext.xml我有这个bean定义

<bean id="applicationProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
<property name="locations"> 
<list><value>classpath:config/application.properties</value></list> 
</property> 
</bean> 

这是文件的内容:

templateName = BLE_NORDIC 

,但是当我在JSP中读取此属性我得到了????

<fmt:message key="templateName"/>' > 

回答

1

将它们添加为消息资源包

message.properties

TEMPLATENAME = BLE_NORDIC

<bean id="messageSource" class="org.springframework.context.support.ReloadableResourceBundleMessageSource"> 
    <property name="basenames"> 
     <list> 
     <value>message</value> 
     </list> 
    </property> 
    </bean>