Chaos2018

关于springboot的static和templates

  最近搭建springboot练习项目的时候,将index.html文件放在templates文件下。项目启动之后,直接访问localhost/index.html报路径错误的提示。而使用restful风格的路径跳转就可以,网上搜索资料之后,得出结果是springboot默认的静态访问路径是static,而templates是默认的动态访问路径。

      由此产生的问题是,如何设置让springboot的默认访问路径是templates。

      解决的办法是将templates设置为静态路径,在application.properties中加入以下。

 spring.resources.static-locations=classpath:/templates/

 由此又产生的问题是在restful访问url的时候,路径会不会产生影响,毕竟springboot默认的动态访问路径是templates。待查。

 

posted on 2019-08-20 08:21  Chaos2018  阅读(863)  评论(0编辑  收藏  举报

导航