Class StaticFilesServlet

java.lang.Object
jakarta.servlet.GenericServlet
jakarta.servlet.http.HttpServlet
org.apache.juneau.rest.server.servlet.RestServlet
org.apache.juneau.rest.server.staticfile.StaticFilesServlet
All Implemented Interfaces:
jakarta.servlet.Servlet, jakarta.servlet.ServletConfig, Serializable

public class StaticFilesServlet extends RestServlet
Standalone servlet companion of the StaticFilesMixin mixin.

Mounts as a sibling top-level servlet at /static/* and serves static files by delegating to the flavor-neutral StaticFiles worker bean resolved from the request context (RestContext.getStaticFiles()) — the same worker the mixin and child flavors use, so the forms cannot drift.

Whereas the StaticFilesMixin mixin pins its op at /static/* for composition into a host at /, this companion declares the mount at the class level (@Rest(paths="/static/*")) and pins the ops at /* — eliminating the path-doubling that a mixin-shaped op would produce when the servlet itself is mounted at /static/*.

Microservice registration:

@Bean Servlet staticFiles() { return new StaticFilesServlet(); // auto-mounted at /static/* by JettyServerComponent }

See Also:
Since:
10.0.0