Reputation: 161
Is there a real alternative to JSP tags when using Spring MVC?
I'm using Spring MVC to integrate it to a JS framework. What i'm missing in Spring MVC is a kind of templating framework
I have previously used Facelets templating with JSF2 and I love it.
Is there a framework/technology that integrates well with Spring MVC and offers similar features as Facelets?
I was looking at Apache Tiles documentation and it seems that you need to have separate files for each section in template.
Example (pseudocode) :
template.html:
<insert:headerSection>
<insert:bodySection>
using-template.html:
<use-template: template.html>
<define:headerSection>this is a header</define:headerSection>
<define:bodySection>this is a body</define:bodySection>
I know that I can achieve this using JSP but code looks much cleaner and faster to write using Facelets.
If JSP is my best choice I found some suggestions in this thread
Upvotes: 1
Views: 3106
Reputation: 361
I consider that frameworks to make templating are getting deprecated. In this regard, you could think about exposing a Restful API, so that you can separate back-end from front-end technologies. This way you can use the benefits of Spring-MVC in back-end and letting the Front-end to decide the technology to build user interfaces (AngularJS).
Spring-MVC supports the build of Restful controllers, you just need to mark your classes as @RestController.
Upvotes: 0
Reputation: 361
What about freemarker or velocity, there's a clear explanation about how to integrate those technologies with Spring MVC. Take a look at the following: http://static.springsource.org/spring/docs/3.2.x/spring-framework-reference/html/view.html
Upvotes: 1
Reputation: 1329
It is possible to configure Facelets with Spring MVC. Check it out here: https://github.com/acichon89/springmvcfacelets
Upvotes: 0
Reputation: 161
After some testing with Tiles I decided to go with JSP.
I needs no configuration and I achieved the above functionality writing a simple tag file and using <jsp:attribute/>
and <jsp:invoke/>
tags.
Upvotes: 1
Reputation: 8154
I think Spring Webflow has JSF 2 support. If you want to stick with pure Spring MVC, it also offers templating with Tiles and Velocity, or you can even write your own custom ViewResolver.
Upvotes: 1