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 访问文件
相关文章推荐
- 简单快速的用SpringBoot访问静态资源(图片、html)
- idea中spring boot 修改静态资源(js,html) 和 java 不能立即生效,必须重启的解决方案
- spring boot 学习笔记(003) 静态资源(html/js等文件)
- Spring Boot无法访问css,js等静态资源的问题
- 解决spring boot中swagger-ui.html访问404以及配置全局header
- Spring Boot 设置静态资源访问
- Spring中拦截/和拦截/*的区别 - 不能访问到返回的JSP - 访问静态资源(jpg,js等)
- IntelliJ IDEA+SpringBoot中静态资源访问路径陷阱:静态资源访问404
- 纯静态html页面,js 如何拦截请求url的后缀不是.html的访问地址
- 备忘:在web.xml中使用org.springframework.js.resource.ResourceServlet的配置对静态资源的访问
- Spring boot 默认静态资源路径与手动配置访问路径的方法
- Spring中拦截/和拦截/*的区别 - 不能访问到返回的JSP - 访问静态资源(jpg,js等)
- Spring中拦截/和拦截/*的区别 - 不能访问到返回的JSP - 访问静态资源(jpg,js等)
- (五)Spring Boot配置静态资源访问,整合Thymeleaf模板
- web.xml中配置访问资源URL<url-pattern>/</url-pattern>时无法访问.html、.jsp、.js、.css等静态资源时的解决方案
- Spring MVC中访问静态资源(如html, js, css等)
- SPRING-MVC访问静态文件,如jpg,js,css
- web.xml中配置访问资源URL<url-pattern>/</url-pattern>时无法访问.html、.jsp、.js、.css等静态资源时的解决方案
- SpringBoot学习历程(3)->springboot中对静态资源的访问
- springboot项目访问静态资源(默认方式)