Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Use Twirl with Spring MVC

Is it possible to use Twirl with Spring MVC as the view technology? I would like to use something in place of JSP, and Apache Tiles feels cumbersome to me. Twirl the view technology for the Play Framework looks very cool, and similar to ASP.NET Razor.

https://www.playframework.com/documentation/2.3.x/JavaTemplates

I did a quick Google search but did not uncover much.

like image 899
greyfox Avatar asked Sep 13 '25 03:09

greyfox


1 Answers

I didn't used Play Framework so I'm not familiar with it's architecture. But I found your question interesting and did some research.


Twirl Template Engine with Spring MVC Demo App

But I did found some useful resources that might help your case.

Spring MVC Twirl GitHub

This repository has an identical example of what you're looking for.

To be honest, I haven't tried to run this code myself but it seems like a trustworthy user.


Also, I did found a Blog Example which explains how to run Twirl Template Engine standalone without Play Framework. This doesn't cover your use-case but it suggests it's possible to use Twirl Template Engine without Play Framework (hence with right configs it's possible to use it with Spring)

Standalone Twirl Template Engine Usage Example - Blog and GitHub Repo

Standalone Twirl Template Engine Usage

Standalone Twirl Template Engine Usage GitHub Repository


Different Template Engines for Spring - Does not mention Twril

Also, if you wan't a great reading reference I always visit Baeldung website

I found a blog post about different template engines for Spring. They don't cover your use case, but based on this article it is possible to use variety of different engines given that you have proper dependency (e.g. maven, gradle) and do a proper configuration.

Does not mention Twirl, but it might give you some idea how to do it

Template Engine for Spring Blog Post

like image 57
Aleksandar Trifunovic Avatar answered Sep 15 '25 18:09

Aleksandar Trifunovic