Setting the Welcome Page in Spring Web MVC

In any Spring Web MVC application, there is a need to set the default landing or welcome page.

Traditionally in Java web applications, this is done in the web.xml file as so:

Or in a spring web mvc application, it might be like this:

With a corresponding controller class RequestMapping:


This is ok, because “/” is a valid existing URL but, if the required welcome page is to be a virtual URL such as /person/list a little more creativity is required.


 Note the additional URL pattern in the <servlet-mapping>

This essentially makes the welcome page valid as far as the application server is concerned because it is a valid servlet url mapping. Spring will handle subsequent requests independently of the application server.



For a fully worked example where this exact method is used see this blog.

Comments always welcome….