Reputation: 8721
In my application context I have defined properties file:
<context:property-placeholder location="classpath:application.properties" />
I want to get value of the property defined in that file on JSP page. Is there a way to do that in the way
${something.myProperty}?
Upvotes: 15
Views: 27570
Reputation: 307
`<bean class="org.springframework.context.support.ReloadableResourceBundleMessageSource"
id="messageSource"
p:basenames="WEB-INF/i18n/site"
p:fallbackToSystemLocale="false"/>`
Now this is your Properties File
`site.name=Cool Bananas`
And. Here goes your JSP
`<%@ taglib uri="http://www.springframework.org/tags" prefix="spring" %>
<html>
<head>
<title><spring:message code="site.name"/></title>
</head>
<body>
</body>
</html>`
Upvotes: 0
Reputation: 20297
PropertyPlaceholderConfigurer
can only parse placeholders in Spring configuration (XML or annotations). Is very common in Spring applications use a Properties
bean. You can access it from your view this way (assuming you are using InternalResourceViewResolver
):
<bean id="properties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<property name="locations">
<list><value>classpath:config.properties</value></list>
</property>
</bean>
<bean class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="prefix" value="/WEB-INF/views/"/>
<property name="suffix" value=".jsp"/>
<property name="exposedContextBeanNames">
<list><value>properties</value></list>
</property>
</bean>
Then, in your JSP, you can use ${properties.myProperty}
or ${properties['my.property']}
.
Upvotes: 38
Reputation: 1
This will show you the tables of the current schema (which you are logged in):
select table_name from user_tables order by table_name;
This will show you the tables of schema , for which you have select rights at least:
select owner, table_name from all_tables where owner='<owner>' order by owner, table_name;
Upvotes: -4
Reputation: 3830
After Spring 3.1, you can use <spring:eval />
tag with SpEL like this:
<spring:eval expression="@applicationProps['application.version']"
var="applicationVersion"/>
Upvotes: 6
Reputation: 7779
To use recursive property placeholder expansion in views, you need a different solution, take a look at this answer:
https://stackoverflow.com/a/10200249/770303
Upvotes: 0
Reputation: 11
To use with multiple locations in a list which might not be present as can be done with the context:property-placeholder bean:
<beans:bean id="appProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean">
<beans:property name="ignoreResourceNotFound" value="true" />
<beans:property name="locations">
<beans:list>
<beans:value>classpath:application.properties</beans:value>
<beans:value>classpath:environment.properties</beans:value>
<beans:value>classpath:environment-${env}.properties</beans:value>
</beans:list>
</beans:property>
</beans:bean>
Upvotes: 0