Search code examples
spring-bootapplicationcontext

append application context path to the hyperlink in spring boot application


I added the following command to application.properties file.

server.contextPath=/SpringBootOracle

Now, I have a hyperlink in the html page as shown below

<a href="/product/new">New Product</a>

Every time when I click the link, it will jump to

localhost:8080/product/new

Is there any way I can append the application context to the link so that I can get below?

localhost:8080/SpringBootOracle/product/new

Solution

  • If you use thymeleaf then try with this:

    <a th:href="@{/product/new}">New Product</a>