I'm wondering what are the advantages I can get by using Thymeleaf instead of JSP for the view in Spring.
Thymeleaf is way better in my opinion because it have good underlying priciples and exploits natural behaviour of browsers. Jsp makes html hard to read, it becomes weird mixture of html and java code which makes a lot of problems in comunication between designer - developer.
It allows for natural templating, can do complex processing and lets us easily define custom dialects. On top of that, Thymeleaf facilitates the collaboration of both front end and back end developers on the same template file, greatly increasing productivity.
From what I read, Thymeleaf is pretty slow compared to other templating languages, while JSP is very fast, with FreeMarker and Velocity coming close. However, Thymeleaf supports natural templates (templates that will render nicely in your browser even if you don't run them through the template engine).
If you are building web front-ends with Spring Boot or Spring MVC, and you're still using JSP (Java Server Pages) then this course is for you. Thymeleaf is a great templating engine which replaces JSP, and you can easily use it in any Spring MVC or Spring Boot application.
The commonly cited advantages are:
${#calendars.format(...)}
, ${#strings.capitalize(...)}
which are well integrated with Spring e.g. you can pass model beans propagated by Spring MVC into these functions..html
template, edit it and (possibly) edit it's linked .css
file; (2) hit F5
to refresh in the browser; (3) repeat until happy. By contrast, the same activity in a JSP implementation would involve: (1) deploy the application into a development server; (2) start it up; (3) make some changes; (4) redeploy (or hot deploy) the changes; (5) repeat until happy.If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With