2
当前使用spring'exposedContextBeanNames'来允许我在视图中显示属性,但存在一些包含“。”的属性的问题。无法使用exposeContextBeansAsAttributes检索属性
我的XML是设置为
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list><value>classpath:servers.properties</value> </list>
</property>
</bean>
<bean id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="exposeContextBeansAsAttributes" value="true"/>
<property name="exposedContextBeanNames">
<list>
<value>properties</value>
</list>
</property>
</bean>
我 “servers.properties” 有一些价值
的value1=this is the first value
value.value1=this is my second value
在我的JSP
${properties.value1}
会显示“这是第一个值“如预期,但
${properties.value.value1}
不起作用。我希望有人能够帮助我。谢谢
完美的工作。 – user815809 2012-02-07 15:08:50
你知道吗,如果我的属性文件看起来像这样,它是否可以做同样的事情; value1 = $ {my.env.value}在哪里获取envirnoment值。如果我尝试打印这个值,我会得到字符串“$ {my.env.value}”来代替env值。 – user815809 2012-02-07 15:09:35
精湛的答案.. :)谢谢@axtavt :) – 2014-06-13 04:20:08