Springboot整合freemarker出现404问题怎么办

小编这次要给大家分享的是Springboot整合freemarker出现404问题怎么办,文章内容丰富,感兴趣的小伙伴可以来了解一下,希望大家阅读完这篇文章之后能够有所收获。

今天遇到了ftl整合springboot出现的问题

@Controller
public class IndexController {

  @RequestMapping("hello")
  public String index(){
    System.out.println("aaa");
    return "index";
  }
}

在浏览器输入 localhost:8080/hello 控制台也打印了aaa,index.ftl也写的没有问题。就是出现了这个问题。

Springboot整合freemarker出现404问题怎么办

解决办法:查看源码,原来默认的是.ftlh结尾的,当然就会出现上面的错误。

Springboot整合freemarker出现404问题怎么办

修改办法,在application.properties配置文件中添加如下配置

spring.freemarker.suffix=.ftl

看完这篇关于Springboot整合freemarker出现404问题怎么办的文章,如果觉得文章内容写得不错的话,可以把它分享出去给更多人看到。