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升级失败


基础教程推荐
- Spring AOP错误无法懒惰地为此建议构建thisJoinPoin 2022-09-13
- RabbitMQ:消息保持“未确认"; 2022-01-01
- 如何对 Java Hashmap 中的值求和 2022-01-01
- REST Web 服务返回 415 - 不支持的媒体类型 2022-01-01
- 问题http://apache.org/xml/features/xinclude测试日志4j 2 2022-01-01
- Struts2 URL 无法访问 2022-01-01
- 存储 20 位数字的数据类型 2022-01-01
- 修改 void 函数的输入参数,然后读取 2022-01-01
- 使用堆栈算法进行括号/括号匹配 2022-01-01
- 无法复制:“比较方法违反了它的一般约定!" 2022-01-01