To set up layout pages in Spring you could use SiteMesh. The way you set it up is as follows:
Add the latest version of sitemesh to your pom file, during this writing it was v2.4.2

Create a new decorators.xml file within the WEB-INF folder, this file is used to describe where your layout page is, when it should be used. Here I am telling it that my layout.jsp page is in a folder called shared and that it should be used for any url patterns.

Now add the following two lines in your web.xml file

And finally extract all of the common UI elements into the layout.jsp file. Notice the keyword “decorator”, basically the requested page will be decorated by this layout page.

And here is the hello.jsp page. The layout’s title element will be replaced by “This is hello’s title” and everything else will be put within the body

