Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Alternatives to JSP for Spring MVC view layer

I'm looking to create a new app from scratch and will probably use Spring MVC and possibly Spring Web Flow. The projects created by Spring Roo use Spring MVC and optionally Web Flow. What are some good alternatives for view technology, or is JSP with Spring and JSTL taglibs and jQuery the way to go?

like image 612
digitaljoel Avatar asked Apr 30 '10 17:04

digitaljoel


People also ask

Is Thymeleaf better than JSP?

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.

Is JSP view technologies supported by Spring MVC?

Using Spring's form tag library. As of version 2.0, Spring provides a comprehensive set of data binding-aware tags for handling form elements when using JSP and Spring Web MVC. Each tag provides support for the set of attributes of its corresponding HTML tag counterpart, making the tags familiar and intuitive to use.

Is JSP required for Spring?

Short answer: no, you don't need to learn Servlets and JSPs as a pre-requisite for Spring MVC and many other Java web frameworks.


2 Answers

I recently discovered Thymeleaf.

It looks to be a complete replacement for JSPs and has integration with Spring MVC. The template approach looks more like HTML and may be more palatable to your UI designers. They have a small write-up that compares the two solutions side-by-side.

like image 59
Shawn Sherwood Avatar answered Oct 13 '22 06:10

Shawn Sherwood


In the standard Java EE API, the only alternative to JSP is Facelets. As far now (2010) JSF is the only MVC framework which natively supports Facelets.

Spring MVC supports out of the box only JSP, but it has a configurable view resolver which allows you to use Facelets anyway. Other candiates are 3rd party templating frameworks such as Velocity, Freemarker, and Thymeleaf which can be configured as a view technology for Spring MVC. Spring documentation has integration examples with Velocity and Freemarker.

like image 39
BalusC Avatar answered Oct 13 '22 04:10

BalusC