【Thymeleaf】获取绝对路径

使用Thymeleaf模板引擎想要拼出绝对路径

<a th:href="${#httpServletRequest.getScheme() + '://' + #httpServletRequest.getServerName() + ':' + #request.getServerPort()  + #request.getContextPath() + @{/login}} ">点我啊!</a>
  • getScheme()获取协议
  • getServerName()获取服务器名
  • getServerPort()服务器端口
  • getContextPath() APP根路径

猜你喜欢

转载自blog.csdn.net/sayyy/article/details/80858392