Spring Boot Freemarker fails from 2.2.0 upgrade(Spring Boot Freemarker从2.2.0升级失败)
问题描述
将Spring-Boot-Parent升级到2.2.0.RELEASE
时,我的基于Freemarker的Spring Boot Web应用程序无法正确处理请求。
我有一个@Controller
为/hello
提供服务的src/main/resources/templates/hello.ftl
。
@Controller
class HelloController() {
@RequestMapping(value = ["/hello"])
fun hello(): String {
return "hello"
}
}
根据请求,它只会出现错误页面,上面写着There was an unexpected error (type=Not Found, status=404).
。
错误堆栈跟踪不能说明什么。它只写着org.springframework.web.servlet.resource.ResourceHttpRequestHandler: Resource not found
。
我的pom.xml
基本情况如下:
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifactId>
<version>2.2.0.RELEASE</version>
<relativePath/>
</parent>
<dependencies>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-web</artifactId>
</dependency>
<dependency>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-freemarker</artifactId>
</dependency>
</dependencies>
在升级到Spring Boot 2.2.0版本之前,它一直运行得很好。
这里有什么问题?
- 根据rules,这是一个自我回答的问题,以防止其他可怜的人像我一样受苦。
推荐答案
这是由于Spring Boot 2.2.0中使用默认免费标记后缀的突破性更改。
Freemarker文件现在应该以.ftlh
而不是.ftl
结尾。
.ftlh
启用HTML自动转义功能。
您应该在升级前阅读的2.2.0.RELEASE
的完整更改日志here。
这篇关于Spring Boot Freemarker从2.2.0升级失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:Spring Boot Freemarker从2.2.0升级失败


基础教程推荐
- Java 实例变量在两个语句中声明和初始化 2022-01-01
- 验证是否调用了所有 getter 方法 2022-01-01
- Java Swing计时器未清除 2022-01-01
- 大摇大摆的枚举 2022-01-01
- 在 Java 中创建日期的正确方法是什么? 2022-01-01
- 多个组件的复杂布局 2022-01-01
- 不推荐使用 Api 注释的描述 2022-01-01
- 如何在 Spring @Value 注解中正确指定默认值? 2022-01-01
- 从 python 访问 JVM 2022-01-01
- 如何在 JFrame 中覆盖 windowsClosing 事件 2022-01-01