Static Content Support
Use the StaticContentSupport class to serve files and classpath resources. StaticContentSupport can be created for any readable directory or classpath context root and registered on a path in Routing.
You can combine dynamic handlers with StaticContentSupport objects: if no file matches the request path, then the request is forwarded to the next handler.
Routing.builder()
.register("/pictures", StaticContentSupport.create(Paths.get("/some/WEB/pics"))
.register("/", StaticContentSupport.builder("/static-content")
.welcomeFileName("index.html")
.build());content_copy
- Create a new
StaticContentSupportobject to serve data from the file system, and associate it with the"/pictures"context path. - Create a
StaticContentSupportobject to serve resources from the contextualClassLoader. The specific classloader can be also defined. A builder lets you provide more configuration values. index.htmlis the file that is returned if a directory is requested.
A StaticContentSupport object can be created using create(…) factory methods or a builder. The builder lets you provide more configuration values, including welcome file-name and mappings of filename extensions to media types.