What template engine should I use in Spring MVC?

Sergey Bakotin picture Sergey Bakotin · Jun 2, 2017 · Viewed 10k times · Source

I'm learning Spring MVC and want to create a site. The main problem is a template system. Should I use JSP / JSF / Apache FreeMarker / Thymeleaf or something else?

I saw a lot of discussion on this subject, but they are all outdated. So, I'm curious, what is fine now?

Answer

McBeelen picture McBeelen · Jun 2, 2017

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:

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.