2014-04-15 63 views
0

我想直接在我的jsp中使用属性文件内的值。我正在使用瓷砖,并尝试了以下事情以使其工作。不能访问瓷砖属性文件的值春天mvc

<!-- Load guide properties file --> 

    <bean id="GuideProperties" 
     class="org.springframework.beans.factory.config.PropertiesFactoryBean"> 
     <property name="locations"> 
      <list> 
       <value>WEB-INF/text/guide.properties</value> 
      </list> 
     </property> 
    </bean> 

    <bean 
     class="org.springframework.web.context.support.ServletContextAttributeExporter"> 
     <property name="attributes"> 
      <map> 
       <entry key="GuidedTut" value-ref="GuideProperties" /> 
      </map> 
     </property> 
    </bean> 

我试图在JSP中访问如下

${GuidedTut.guide.welcome.firstline} 

项目运行良好,但我看不到属性在JSP文件中值。

+1

检查是否HTTP:/ /thinkinginsoftware.blogspot.in/2012/01/access-properties-file-from-jspjstl-el.html将帮助你 – coreJavare

回答

0

你可以得到由propertyplaceholder和使用JSP春天标签在JSP中的属性值: 在您的调度员方面的xml:

<!-- PropertyPlaceHolder --> 
    <util:properties id="propertyConfigurer" location="WEB-INF/test/guide.properties"/> 
    <context:property-placeholder properties-ref="propertyConfigurer"/> 

在你的JSP:

<%@ taglib prefix="spring" uri="http://www.springframework.org/tags" %> 
    ... 
    <spring:eval expression="@propertyConfigurer.getProperty('GuidedTut.guide.welcome.firstline')" /> 
+0

你试过这个吗? – Prasad