springboot升级到2.2.4版本freemarker出现404

星期日, 2020-01-26 | Author: Lee | JAVA-and-J2EE | 2,825 views

今天看到spring mvc 有漏洞提醒升级,就把spring boot从2.1.4版本升级到2.2.4版本

github警告 springmvc 5.0系列5.0.16以下 5.1系列5.1.13以下,5.2系列5.2.3以下,springboot 2.2.4以下都有安全漏洞

换了后没有发现编译错误,启动后试了下,发现页面都是404了,网上查了下,是FreeMarkerViewResolver的缺省配置文件

改了suffix 由原来的ftl 改成ftlh了,详情可以参见源码,现记下处理方式:

1.改原来的ftl文件扩展名ftl改成ftlh 可以解决(对于老工程不适合)

2.修改application.properties 文件

#spring
spring.freemarker.suffix=.ftl
 
更多其他配置:
spring.freemarker.cache=false
spring.freemarker.suffix=.ftl
spring.freemarker.templateLoaderPath=classpath:/templates/
spring.resources.static-locations=classpath:/static/

3.使用java代码更改

import org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver;
 
@Autowired
FreeMarkerViewResolver viewResolver;
//设置即可	
viewResolver.setSuffix(".ftl");

Tags: ,

文章作者: Lee

本文地址: https://www.pomelolee.com/2013.html

除非注明,Pomelo Lee文章均为原创,转载请以链接形式标明本文地址

No comments yet.

Leave a comment

Search

文章分类

Links

Meta