From the course: Complete Guide to Spring MVC
Unlock this course with a free trial
Join today to access over 24,700 courses taught by industry experts.
Static resources - Spring Tutorial
From the course: Complete Guide to Spring MVC
Static resources
- [Narrator] Static resources. At this point in the course, you have created and altered your own static files for our examples. This lesson will be solely dedicated to learning about all the different mechanisms for serving and managing static resources, such as images, JavaScript, CSS files, or other assets. It simplifies tasks like resource versioning, caching, and efficient delivery. Static resources are served using resource handler mappings. These mappings connect specific URL patterns to directories or locations where the resources reside. In this example, I've configed the addResourceHandler with the endpoint of resources. This maps all requests starting with resources in the endpoint to these specified resource location. Next we have addResourceLocations. This defines where resources are located. So for this example, it would be /public for files and your project at classpath:/static for resources package in the application JAR. And finally, we have setCacheControl. This…
Practice while you learn with exercise files
Download the files the instructor uses to teach the course. Follow along and learn by watching, listening and practicing.