<%= request.getContextPath()%>相当于Thymeleaf

时间:2017-11-29 10:17:21

标签: java spring spring-boot thymeleaf

我使用Spring Initializer,嵌入式Tomcat,Thymeleaf模板引擎和包作为可执行的JAR文件生成了一个Spring Boot Web应用程序。

使用的技术:

Spring Boot 2.0.0.M6,Java 8,maven

我在application.properties

中定义了此属性
server.servlet.context-path=iberiaWebUtils

我想知道在我的Thymeleaf模板中是否有相当于

的东西
<a href="/<%=request.getContextPath()%>/iberiaReport/download">

1 个答案:

答案 0 :(得分:3)

您可以使用

获取server.servlet.context-path
${#httpServletRequest.getContextPath()}

你可以写

<a href="@{/iberiaReport/download}">