Configuring custom static path mappings

In the previous recipe, we looked at how to tune the URL path mapping for requests and translate them into controller methods. It is also possible to control how our web application deals with static assets and the files that exist on the file system or are bundled in the deployable archive.

Let's say that we want to expose our internal application.properties file via the static web URL of http://localhost:8080/internal/application.properties from our application. To get started with this, proceed with the steps in the next section.

How to do it…

  1. Let's add a new method, addResourceHandlers, to the WebConfiguration class with the following content:
    @Override public void addResourceHandlers(ResourceHandlerRegistry ...

Get Spring Boot Cookbook 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.