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:
- The addResourceHandler method takes a URL pattern and configures it to be static locations which must be served by the server. In the preceding code, all of our static URLs should...