springboot 2.3.0+版本以上,springboot自动引用freemarker模板文件的后缀从.ftl变成了.ftlh
<!DOCTYPE html>
<#escape x as x?html>
<#include "../common/macro.ftl">
<html lang="en">
</html>
</#escape>
而且,如果使用如上述的freemarker代码段,会报Using the "escape" directive (legacy escaping) is not allowed when auto-escaping is on with a markup 的错误,意思就是重复escape。
因为会帮你默认
<#escape x as x?html>
</#escape>
然后你的代码里也加了这个的话,就会2次escape,所以删掉你模板里的escape语句即可
stackoverflow也有类似的问题Freemarker 2.3.24 auto-escape and spring.ftl macros issue - Stack Overflowhttps://stackoverflow.com/questions/37298463/freemarker-2-3-24-auto-escape-and-spring-ftl-macros-issue