My Spring boot web application runs smoothly as an executable jar, but when I build it as a war and deploy it to Tomcat, the CSS and JS files fail to load. Upon further investigation, I discovered that all links are pointing to the root context path "/"
I attempted changing base href = "./"
, which resolved the issue of loading CSS and JS, but this change needs to be implemented on many pages.
Additionally, the links in <a>
still point to the root context path, requiring a prefix of './'
to function correctly. Below are snippets of my code:
CSS and JS link
<link href="css/bootstrap.min.css" rel="stylesheet">
<link href="css/signin.css" rel="stylesheet">
<script src="js/popper.min.js"></script>
<script src="js/bootstrap.min.js"></script>
Tag
<a class="topHeader" href="/activateAccount"></a>
Is there a more efficient solution to address this issue, or should I manually update <base href>
and <a href>
in all pages? Any assistance would be greatly appreciated.