Search code examples
spring-bootthymeleaf

How to access contextPath in Thymeleaf?


I wanted to access contextPath in thymeleaf without setting org.springframework.ui.Model. I configured context path in application.properties file


Solution

  • If you are using Thymeleaf, you should be able to use

    <a th:href="@{/XXX}">Link Name</a> 
    

    assuming that has been declared.

    I think this does require using SpringTemplateEngine.