I want to access the environment properties:
<h1 th:text="${@environment.getProperty('site.name1')}">
<span th:text="${@environment.getProperty('site.name2')}"></span>
</h1>
but I don't get anything for site.name2
even it exists in application.property
file
here my application.properties file:
spring.h2.console.enabled=true
spring.h2.console.path=/h2-console
spring.h2.console.settings.trace=false
spring.h2.console.settings.web-allow-others=false
site.name1=plats
site.name2=bruts
spring.messages.encoding=UTF-8
spring.thymeleaf.encoding=UTF-8
spring.servlet.multipart.max-file-size=1000MB
spring.servlet.multipart.max-request-size=1000MB
spring.servlet.multipart.enabled=true
server.port=8080
This is how it looks using:
<h1>Plats
<span class="muellerhoff">Bruts</span>
</h1>
and with:
<h1>
<span th:text="${@environment.getProperty('site.name1')}"></span>
<br/>
<span class="muellerhoff" th:text="${@environment.getProperty('site.name2')}"></span>
</h1>
question from:
https://stackoverflow.com/questions/65541130/thymeleaf-access-environment-bean 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…