如何在基于Spring的Web应用程序中显示内部版本号 [英] How to display buildnumber in spring-based web application
问题描述
我需要在index.jsp页面上显示内部版本号
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>Title (build: BUILDNUMBER )
</head>
内部版本号可以由maven提供到* .properties文件中. 用Spring读取* .properties文件并显示属性的最佳方法是什么?
您可以将 JSP文件: I need to display build number in my index.jsp page 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 where Context configuration: JSP file:
这篇关于如何在基于Spring的Web应用程序中显示内部版本号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!.properties
文件作为本地化消息源加载(使用Version: <spring:message code = "buildNumber" />
pom.xml
:<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>
<!DOCTYPE HTML>
<html>
<head>
<meta charset="UTF-8" />
<title>Title (build: BUILDNUMBER )
</head>
.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}
buildNumber
is exposed as Roland Schneider suggests.<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>
Version: <spring:message code = "buildNumber" />
pom.xml
:<resources>
<resource>
<directory>src/main/resources</directory>
<filtering>true</filtering>
</resource>
</resources>