将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
基本情况如下:
org.springframework.boot
spring-boot-starter-parent
2.2.0.RELEASE
org.springframework.boot
spring-boot-starter-web
org.springframework.boot
spring-boot-starter-freemarker
在升级到Spring Boot 2.2.0版本之前,它一直运行得很好。
这里有什么问题?
这是由于Spring Boot 2.2.0中使用默认免费标记后缀的突破性更改。
Freemarker文件现在应该以.ftlh
而不是.ftl
结尾。.ftlh
启用HTML自动转义功能。
您应该在升级前阅读的2.2.0.RELEASE
的完整更改日志here。
这篇关于Spring Boot Freemarker从2.2.0升级失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持吉威生活!
[英文标题]Spring Boot Freemarker fails from 2.2.0 upgrade
声明:本媒体部分图片、文章来源于网络,版权归原作者所有,如有侵权,请联系QQ:330946442删除。