Nuñito Calzada
Nuñito Calzada

Reputation: 2056

Thymeleaf HREF server context

I have a basic SpringBoot 2.0.4.RELEASE app. using Spring Initializer, JPA, embedded Tomcat, Thymeleaf template engine, and package as an executable JAR file.

I have this href in a button that is working fine

<input type="button" value="CANCEL" th:onclick="'window.location.href = \'' + @{/user/list/} + '\''"  />

nevertheless I have a href, where I have to put also the server.servlet.context-path defined the the application.properties file, otherwise the link goes to http://127.0.0.1/user/list

 <a href="/myapp/user/list" class="pure-menu-link">
                       <i class="fa fa-id-card-o fa-lg fa-fw"></i>&nbsp; USERS
                   </a>

Upvotes: 0

Views: 230

Answers (1)

Metroids
Metroids

Reputation: 20477

You can use th:href just like you're doing for your JavaScript:

<a th:href="@{/user/list/}" class="pure-menu-link">
  <i class="fa fa-id-card-o fa-lg fa-fw"></i>&nbsp; USERS
</a>

Upvotes: 1

Related Questions