Mastering Spring 5.0
上QQ阅读APP看书,第一时间看更新

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.