> For the complete documentation index, see [llms.txt](https://jack80342.gitbook.io/spring-boot/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://jack80342.gitbook.io/spring-boot/iv.-spring-boot-features/27.-developing-web-applications/27.2-the-spring-webflux-framework/27.2.3-static-content.md).

# 27.2.3 静态内容

默认情况下，Spring Boot从类路径下的`/static`（或者是`/public`、`/resources`、`/META-INF/resources`）文件夹提供静态内容。这是通过Spring WebFlux的`ResourceWebHandler`实现的。你可以添加你自己的`WebFluxConfigurer`并覆写`addResourceHandlers`方法来改变该行为（加载静态文件）。

默认地，资源放置在`/**`，但是你可以通过`spring.webflux.static-path-pattern`属性进行调整。例如，迁移所有的资源到`/resources/**`可以按照如下方式实现：

```
spring.webflux.static-path-pattern=/resources/**
```

你可以设置`spring.resources.static-locations`属性自定义静态资源的位置（配置一系列目录位置代替默认的值）。这样，Spring Boot会在你自定义的位置查找欢迎页。所以，要是在哪个位置有`index.html`，它就会是应用的主页。

此外，除了上述标准的静态资源位置，有个例外情况是[Webjars内容](http://www.webjars.org/)。任何在`/webjars/**`路径下的资源都将从jar文件中提供，只要它们以Webjars的格式打包。

**注** Spring WebFlux应用并不完全依赖Servlet API，所以它们不能用war文件部署，也不使用`src/main/webapp`目录。
