Thymeleaf provides an easy way to create URLs using link expressions @{...}.
In this article, we will use context-relative URLs in Thymeleaf template.
This kind of URLs are the most used ones in web applications. Context-relative URLs are relative to the web application root context configured on the server.
For example, if your Spring Boot application using context path, so there is a
server.contextPath=/myapp
parameter in your application.properties
, the myapp
will be the context name.
Context-relative URLs start with
/
.
For example, link provided like the following:
for application served on
myapp
context, the output will look like the following:
for application served without root context, the output will be the following:
Comments
Post a Comment