I need to display build number in my index.jsp page
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>Title (build: BUILDNUMBER )
</head>
The build number can be supplied by maven into a *.properties file. What is the best way to read *.properties file and display a property with Spring?
You may load the .properties
file as a localization message source (using ResourceBundlerMessageSource
) and access it in JSP using <spring:message>
or <fmt:message>
:
src/main/resources/buildInfo.properties
:
buildNumber=${buildNumber}
where buildNumber
is exposed as Roland Schneider suggests.
Context configuration:
<bean id="messageSource" class="org.springframework.context.support.ResourceBundleMessageSource">
<property name = "basenames"><value>buildInfo</value></property>
<!-- Or a comma separated list if you have multiple .properties files -->
</bean>
JSP file:
Version: <spring:message code = "buildNumber" />
pom.xml
:
<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With