简体   繁体   English

在JSP上使用jstl setBundle从jar读取属性文件

[英]Read properties file from jar using jstl setBundle on JSP

All my web app are using a comum JAR file. 我所有的Web应用程序都使用comum JAR文件。 I'd like to get my framework version, that is into a .properties file, and show it on footer page. 我想将我的框架版本保存到.properties文件中,并将其显示在页脚页面上。

I want to read this properties using jstl setBundle tag. 我想使用jstl setBundle标记读取此属性。

This is the version.properties file: 这是version.properties文件:

deploy_version=1.02
data_deploy=2013/06/04 14\:08
computador_deploy=EG1188930
usuario_deploy=1542069

I'm trying this on my jsp, but I'm getting any value: 我正在我的jsp上尝试此操作,但是却获得了任何价值:

<fmt:setBundle basename="br.gov.company.framework.version" var="framework"/>
<fmt:message key="deploy_version" bundle="${framework}"/>

The JAR file is located into \\WEB-INF\\lib. JAR文件位于\\ WEB-INF \\ lib中。

Is there another way to get this from JSP? 是否有另一种方法可以从JSP获得此信息? Or do I have to get it from Java getResourceAsStream? 还是我必须从Java getResourceAsStream获得它?

Tnks! TNKS!

The properties file is at the root of the jar file. 属性文件位于jar文件的根目录。 So its basename is not br.gov.company.framework.version , but simply version : 因此,它的基本名称不是br.gov.company.framework.version ,而是简单的version

<fmt:setBundle basename="version" var="framework"/>
<fmt:message key="deploy_version" bundle="${framework}"/>

You would use br.gov.company.framework.version as the base name if the path of the file in the jar was /br/gov/company/framework/version.properties 你会使用br.gov.company.framework.version基名称,如果该文件的罐中的路径是/br/gov/company/framework/version.properties

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM