Spring MVC Configurations

Add code in XML file “WEB-INF/web.xml” for defining and configuring Spring MVC dispatcher servlet(s).


Then, we setup URL mapping of dispatcher servlet(s) we’ve just defined. This means all requests coming in (since the url-pattern is “/” below) should be handled by dispatcher called “JbkDispatcher”.



Now, when you make a request, this will be mapped to a specific dispatcher. And so, Spring will load the configuration of that dispatcher from “WEB-INF” folder. In this case, our file is “WEB-INF/spring-mvc-demo-servlet.xml”.

We can add support for features like Spring component scanning, conversions, formatting, validation, configure Spring MVC View Resolver.


The “prefix” and “suffix” will be used to render the view page.

We need to create “view” folder inside the “WEB-INF” folder.

I’m assuming you’ve created a package called “com.javabykiran” where all of your Java classes live.



Any static resource is processed as a URL mapping in Spring MVC.

You can configure references to static resources by adding the following entry to the configuration file of the Dispatcher Servlet.

The double asterisk “**” means to look also for the subdirectory.

In your view pages, we can access the static files using one of the following:

OR