Choosing between Thymeleaf and Angular for a new Spring MVC project

davioooh picture davioooh · Jun 1, 2017 · Viewed 32.9k times · Source

I'm starting a new Spring Boot web application and I need to make a choice about how to implement front-end.

I'm really comfortable with Thymeleaf templating framework that I used in several projects, but I'm evaluating Angular (v2) as a possible alternative.

I'm quite new to client-side MVC frameworks and I'd like to understand if there are some guidelines to decide which option is the best for a web project.

I've read a lot of posts and tutorials about this, but they all seem to describe personal opinions or to be just coding experiments...

  1. Are there some application requirements that objectively suggest to use a client-side approach instead of a server-side implementation?

  2. Is it possible and effective to use both the technologies together?

Answer

Erik Pearson picture Erik Pearson · Jun 2, 2017

Thymeleaf and AngularJS are not mutually exclusive. You can certainly use them together, depending on what you are trying to accomplish. If you are all in on writing a single-page dynamic web application, Thymeleaf is probably unnecessary.

Speaking to your question about client side frameworks vs. server-side ones, I'm an Enterprise Software Engineer, so I am not creating commercial software and my priority is less about how pretty it looks (a little Bootstrap does the trick) and more about stability, browser compatibility (even with older browsers), and maintainability. I personally avoid the single page, dynamic web applications because I find the code base more difficult to manage in non-trivial applications; a large Javascript code base can be a bear, in my opinion. Building up my pages primarily on the server side provides me with better debugging capabilities (Java is going to give you a lot of compile time help that you don't get with Javascript) and easier logging. I do use javascript (mostly just jquery) on the client side, but generally my web apps are built to degrade gracefully if the user has javascript turned off. Again, these are internal, utilitarian, applications to support the business. I don't have time to write a whole thesis on the subject and there are plenty of nuances that I'm not covering, but hopefully this is useful.

If you need your web app to act more like a mobile or desktop application, then single-page dynamic web app using a framework like AngularJS is one way to go.