Configure Spring MVC resource handler to deliver WebJar static content

This is very simple. We need to add the following mapping to the spring context:

    <mvc:resources mapping="/webjars/**" location="/webjars/"/>

With this configuration, ResourceHttpRequestHandler makes the content from WebJars available as static content.

As discussed in the section on static content, we can specifically cache a period if we want to cache the content.

Get Mastering Spring 5.0 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.