What template engine should I use in Spring MVC?

You can use any of them as they are supported. JSP, FreeMaker and Thymeleaf are similar by idea: you create a template to be rendered. JSP and FreeMaker lacks some features that are available in Thymeleaf.

I like Thymeleaf's idea where you can load your template to the browser and see how the page is going to be rendered (real). Thymeleaf template is fully featured HTML page. That's not possible in JSP where you have JSP tags and FreeMaker where you have placeholders.

JSF is component based so that's a different approach.

If I have to choose I would use Thymeleaf.


The best practices for server-side rendering have shifted towards using a template engine. These get the responsibility to merge the data with the template into the actual output.

Current preferences appear to be:

  • Thymeleaf
  • FreeMarker

JSP's and JSF are entirely different things and have become out of fashion.

The big plus for using an actual template engine is that you are forced to separate the concerns of gathering the data to present and rendering it; this separation allows you to (unit) test the templates.

Note, however, that the industry is shifting once more towards client-side rendering, where the server just returns the data as JSON-objects and the web application uses some framework like Angular, React, jQuery or Ember to build the pages.

Note on the edit: Originally the list included Velocity, but that is no longer supported by Spring.