我想在运行时在 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 的上下文参数中,然后使用 jSTL 在 jsp 中使用它来完成。
关于java - 如何在jsp中检索属性文件名?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/37699292/