如何在JSP中使用PropertyPlaceholderConfigurer中指定的属性文件中的属性

在我的应用程序上下文中,我定义了属性文件

 

我想获得JSP页面上该文件中定义的属性的值。 有没有办法做到这一点

 ${something.myProperty}? 

PropertyPlaceholderConfigurer只能解析Spring配置(XML或注释)中的占位符。 在Spring应用程序中很常见的是使用Properties bean。 您可以通过这种方式从视图中访问它(假设您使用的是InternalResourceViewResolver ):

   classpath:config.properties       properties   

然后,在JSP中,您可以使用${properties.myProperty}${properties['my.property']}

在Spring 3.1之后,您可以使用带有SpEL的 标记,如下所示:

  

要使用列表中可能不存在的多个位置,可以使用context:property-placeholder bean:

     classpath:application.properties classpath:environment.properties classpath:environment-${env}.properties    

要在视图中使用递归属性占位符扩展,您需要一个不同的解决方案,看看这个答案:

https://stackoverflow.com/a/10200249/770303

 `` 

现在这是你的属性文件

 `site.name=Cool Bananas` 

和。 这是你的JSP

 `<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>   <spring:message code="site.name"></spring:message>    ` 

这将显示当前架构的表(您已登录):

 select table_name from user_tables order by table_name; 

这将显示架构表,至少您有选择权限:

 select owner, table_name from all_tables where owner='' order by owner, table_name;