Book Image

Spring MVC Beginner's Guide

By : Amuthan Ganeshan
Book Image

Spring MVC Beginner's Guide

By: Amuthan Ganeshan

Overview of this book

Table of Contents (19 chapters)
Spring MVC Beginner's Guide
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

Serving static resources


So far, we have seen that every request goes through the controller and returns a corresponding view file for the request; most of the time, these view files contain dynamic content. By dynamic content, I mean the model values that are dynamically populated in the view file during the request processing. For example, if the view file is of the JSP type, then we populate model values in the JSP file using the JSP expression notation, ${}.

However, what if we have some static content that we want to serve to the client? For example, consider an image that is static content; we don't want to go through controllers in order to serve (fetch) an image as there is nothing to process or update any values in the model. We simply need to return the requested image.

Let's say we have a directory (/resources/images/) that contains some product images, and we want to serve these images upon request. For example, if the requested URL is http://localhost:8080/webstore/resource/images...