【发布时间】:2016-06-08 10:00:14
【问题描述】:
我想在运行时获取JSP中spring初始化(tomcat容器启动期间)加载的属性文件的名称。
<util:properties id="propertyConfigurer" location="classpath:${devTarget_propertyFileClassPathHere}"/>
<context:property-placeholder properties-ref="propertyConfigurer" />
devTarget 由 Tomcat 的 catalina.properties 文件提供。 并且基于这个值,一个特定的属性文件在 spring init 期间被加载。
现在我想在 JSP 中阅读这个 devTarget 以根据环境呈现一些东西,其中 devTarget 告诉环境。
我该怎么做?这样 devTarget 就可以在 JSP 中轻松访问了。
类似:
<spring:eval expression="@propertyConfigurer.getProperty('propertyNameHere')" />
【问题讨论】:
-
通过将值存储在 web.xml 的 context-param 中,然后在 jsp 中使用 jstl 来完成此操作。
标签: java spring jsp tomcat spring-properties