Alternatives to JSP for Spring MVC view layer [closed]

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?


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.


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.


I recently started going with plain HTML and jQuery for presentation with Spring MVC only creating a JSON view.

So far it's going quite well and even though I have to do the javascript work, it makes for much easier interaction with my designer and quicker turnaround times when he has changes because I don't have to convert his HTML into my JSP. The jury is still out on overall site maintainability.


You can have as many view technologies as you want on Spring MVC. I have FreeMarker and JSP view resolvers. When I run into a view that it's too complicated in FreeMarker (or just more convenient in JSP) I create a JSP view. For instance, Spring with JSTL makes a great job handling forms. For that I use JSP views, but for pretty much everything else I have FreeMarker views.

Have a look to the Spring MVC documentation to see how to configure several view resolvers, basically:

<bean name="freeMarkerViewResolver" class="org.springframework.web.servlet.view.freemarker.FreeMarkerViewResolver">
   <property name="cache" value="true"/>
   <property name="prefix" value=""/>
   <property name="suffix" value=".ftl"/>
   <property name="order" value="1"/> <!--NOTICE THE ORDER-->
</bean>

<bean id="jspViewResolver" class="org.springframework.web.servlet.view.UrlBasedViewResolver">
    <property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
    <property name="prefix" value="/WEB-INF/jsp/"/>
    <property name="suffix" value=".jsp"/>
    <property name="order" value="2"/> <!--NOTICE THE ORDER-->
</bean>