Learning about static resources

A dynamic application often has static parts as well. SpringWebFlux also enables us to configure static resources. Let's suppose that we want to use bootstrap.css in our Thymeleaf application. In order to do this, we have to enable the server to determine the static content. This can be configured as follows:

public class WebfluxConfig implements WebFluxConfigurer {    //Rest Removed for Brevity    @Override    public void addResourceHandlers(ResourceHandlerRegistry registry) {        registry.addResourceHandler("/resources/**")                .addResourceLocations("classpath:/static/");    }}

In the preceding code, the following has occurred:

  1. The addResourceHandler method takes a URL pattern and configures it to be static locations which ...

Get Hands-On Reactive Programming with Reactor now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.