i am building a web application using Spring Boot and HTML pages.
In multiple HTML pages I am using the same navbar:
<ul class="navbar-nav mr-auto"> <li class="nav-item active"> <a href="/home" class="nav-link">Home</a> </li> <li class="nav-item"> <a href="/user/showAllProducts" class="nav-link">All Products</a> </li>
Now I had to change the URL of the API that shows all products (/user/showAllProducts) and I had to change about 10 HTML pages.
Is there an easy way to manage all API URLs in one config file (application.properties?) and directly injecting them in HTML pages?
The list item that will show all products is just one example of many other links in the navbar.
Thanks a lot for your help
The best way to do this is in the context of a partial. If you would like to use something like thymeleaf or jsp you can insert your navbar as one line in each HTML or JSP file and then anytime you change the particular partial file (navbar, header, footer, etc) it will be inserted into whatever page is being displayed in the web app.
Here is a sample in documentation for Spring.
Answered By – Adam Chappell
Answer Checked By – David Goodson (AngularFixing Volunteer)