访问 thymeleaf 模板中的 application.properties 值 [英] Access application.properties value in thymeleaf template

查看:124
本文介绍了访问 thymeleaf 模板中的 application.properties 值的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有一个 spring boot 应用程序,在我的 application.properties 中有一个属性是 url=myurl.net.在同一个应用程序中,我有一个百里香叶 html 模板.我想将 url 值放入该模板中.我在 thymeleaf html 模板中使用以下代码 <font face=arial size=2 >访问网址:</font>${environment.getProperty(‘url’)}

I have one of my spring boot application and inside my application.properties there is one of the property is url=myurl.net. In the same application I have one thyme leaf html template. I wanted to get the url value into that template. I am using the following code inside the thymeleaf html template <font face=arial size=2 > access the url : </font> ${environment.getProperty(‘url’)}

我得到的输出:

访问网址:$(environment.getProperty(‘url’)}

access the url : $(environment.getProperty(‘url’)}

我期待的输出:

访问网址:myurl.net

access the url : myurl.net

我得到的不是实际值,而是相同的文本.有人可以帮我解决这个问题.感谢您的帮助.

Instead of actual value I am getting the same text. Can someone please help me on this. Appreciate your help.

推荐答案

你必须使用

${@environment.getProperty('css.specific.name')} 这将从 application.properties 获取 css.specific.name 属性 文件.

${@environment.getProperty('css.specific.name')} this will fetch css.specific.name property from the application.properties file.

这篇关于访问 thymeleaf 模板中的 application.properties 值的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆