java中thymeleaf获取项目根路径

<a th:href="${#httpServletRequest.getContextPath()}"></a>

如Web项目名称为Demo,那么${#httpServletRequest.getContextPath()}获取到的值为Demo

原文地址:https://www.cnblogs.com/NotPig/p/13085016.html