1. SpringBoot从classpath/static的目录访问静态资源, 注意目录名称必须是static。
2. 使用maven构建SpringBoot的名叫spring-boot-static-resources1项目

3. pom.xml
<project xmlns="http://maven.apache.org/POM/4.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
<modelVersion>4.0.0</modelVersion>
<groupId>com.bjbs</groupId>
<artifactId>spring-boot-static-resources1</artifactId>
<version>0.0.1-SNAPSHOT</version>
<parent>
<groupId>org.springframework.boot</groupId>
<artifactId>spring-boot-starter-parent</artifact

本文介绍如何在SpringBoot中配置并访问位于classpath/static目录下的静态资源,包括HTML页面及图片等,并提供了一个具体的示例项目。
最低0.47元/天 解锁文章
3909

被折叠的 条评论
为什么被折叠?



