首页 > 编程语言 > 详细

关于springboot的static和templates

时间:2019-08-20 10:50:06      阅读:72      评论:0      收藏:0      [点我收藏+]

  最近搭建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。待查。

 

关于springboot的static和templates

原文:https://www.cnblogs.com/Chaos1973-newWorld/p/11380867.html

(0)
(0)
   
举报
评论 一句话评论(0
关于我们 - 联系我们 - 留言反馈 - 联系我们:wmxa8@hotmail.com
© 2014 bubuko.com 版权所有
打开技术之扣,分享程序人生!