您的位置:首页 > 编程语言 > Java开发

spring boot 访问静态html、js

2018-02-18 20:58 399 查看

1 具体

1.1 参考

详细的资料参考 https://spring.io/blog/2013/12/19/serving-static-web-content-with-spring-boot

加载静态资源,会从以下几个路径查找:

/META-INF/resources/

/resources/

/static/

/public/

WebMvcAutoConfiguration 源码如下:

private static final String[] CLASSPATH_RESOURCE_LOCATIONS = {
"classpath:/META-INF/resources/", "classpath:/resources/",
"classpath:/static/", "classpath:/public/" };


1.2 建立 static 文件夹

在项目下,建立 static 文件夹。也可以是这个路径 src\main\resources\static。



1.3 建立html文件

建立文件,路径为static\1.html 。 编写内容为 1。

1.4 访问文件

内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  spring boot 静态html
相关文章推荐