好多人 都说:

在配置文件中加入 

spring.freemarker.request-context-attribute=request

在页面就可以

<#assign ctx=request.contextPath />

但是发现前台依然为 null(可能是我的配置有问题)

后来发现可以这样使用

<#assign ctx=springMacroRequestContext.contextPath />

不需要多余的配置

在Spring Boot+ Freemarker 中获取项目根目录

在Spring Boot+ Freemarker 中获取项目根目录

相关文章: