I’d like to achieve this kind of template functionality:
- Have a template defining header, footer, and common parts of complete (x)html webpage
- When returning String from
@Controllerit will define the view included to specific part of template
Like this:
@Controller
@RequestMapping(value = "/", method = RequestMethod.GET)
public String home(Locale locale, Model model) {
return "home_view";
}
views/home_view.vm
<h2>Content title</h2>
<p>Content text</p>
views/template.vm
<html>
<head>
<title></title>
</head>
<body>
<!-- Header of page -->
#include({context variable which contains "home_view"} + ".vm");
<!-- Footer of page -->
</body>
</html>
If anybody knows CakePHP, this is similar to its template system
How can I do this?
Final solution based on @Nathan Bubna suggestion.
Project is based on Spring MVC template, with Maven controlled resources.
Spring version 3.1.1.RELEASE
/WEB-INF/web.xml
/WEB-INF/spring/servlet/servlet-context.xml
important pom.xml lines