I have a project using springboot 1.5.10, eclipse IDE and Thymeleaf.
In several pages I have redirections like this in jquery:
eg: In a Select Option
$('#month').on('change', function() {
window.location = "/dashboard/operation/month/" + month;
})
eg: In a Button
$('#bFind').click(function() {
var newUrl = "/dashboard/operation/month/";
newUrl += month;
$('a').attr('href', newUrl);
});
Both redirect works great defined in my Controller.
The urls are: http://localhost:8080/dashboard/operation/month/01
But the problem is when I create a war project to deploy it in my apache tomcat 9.0.6 I have to give a name to deploy.
Once you have deployed the url is: http://localhost:8080/mywebapp/dashboard/operation/month/01
and it breaks the stuff...
mywebapp could be another name.
So I have been looking for add context path:
The main info I found is:
What is the Syntax to get Thymeleaf ${pageContext.request.contextPath}
But when I add this to may header.html file I get always undefined
<meta name="ctx" th:content="${#httpServletRequest.getContextPath()}" />
Maybe is there is another way to do this and add the context path correctly.
Any suggestions?
Thanks