I wanted to access contextPath in thymeleaf without setting org.springframework.ui.Model. I configured context path in application.properties file
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.