使用maven在Spring Web MVC 3.2.8中读取属性键

时间:2016-12-07 12:12:08

标签: spring spring-mvc

我的Spring Web模型 - 视图 - 控制器(MVC)框架中有这个类。 Spring Web模型 - 视图 - 控制器(MVC)框架的版本是3.2.8。

在我的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 个答案:

答案 0 :(得分: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>
相关问题