2016-12-07 17 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>