[SPR-1052] Support for jsp taglibs in freemarker templates Created: 17/Jun/05  Updated: 19/Jun/12  Resolved: 04/May/06

Status: Closed
Project: Spring Framework
Component/s: Web
Affects Version/s: None
Fix Version/s: 2.0 M5

Type: New Feature Priority: Major
Reporter: Kaj Hejer Assignee: Rob Harrop
Resolution: Fixed Votes: 4
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified

Attachments: File TaglibFreeMarkerView.zip    
Days since last comment: 11 years, 14 weeks, 5 days ago
Last commented by a User: true
Last updater: Trevor Marshall


It would be nice if Spring had support for jsp taglibs like f.x.

<#assign tolog=JspTaglibs["/WEB-INF/jsp/tolog.tld"]>

as decribed on http://fmpp.sourceforge.net/freemarker/pgui_misc_servlet.html (see the heading "Using JSP custom tags in FTL")

Comment by Kaj Hejer [ 24/Jun/05 ]

There is a thread about this issue in the forum, see http://forum.springframework.org/viewtopic.php?t=905

Comment by Tom Turelinckx [ 04/Jul/05 ]

I wrote an article about this: http://opensource.atlassian.com/confluence/spring/display/INTEGRATE/Using+JSP+taglibs+with+FreeMarkerView

Comment by Tom Turelinckx [ 04/Jul/05 ]

Source code from the article.

Comment by Tom Turelinckx [ 17/Jul/05 ]

FYI, I received this email from someone who's been using the code in my article:

Hi Tom,

Just an update on your code to get JspTaglibs working in Spring
Freemarker installations.....

It seems to work flawlessly. I've migrated all of my functionality to
use the code and seen no problems.

It seems to a good piece of work - I encourage you to get this into
Spring, it something I know that I want, something in the Spring JIRA,
and something I know a few other J2EE people want.

Thanks for a fine piece of work,

Comment by Erik Pedersen [ 20/Oct/05 ]

I tested this implementation. I had to create a new view resolver to make this work the way I needed.

It works great.



Comment by Rob Harrop [ 04/May/06 ]


I updated FreeMarkerView and FreeMarkerConfigurer as appropriate so this should now just work. Can anyone who needs this feature please try it out. I gave it a basic run in a local Tomcat but feedback from a real usage scenario would be great.


Comment by Tom Turelinckx [ 20/Jun/06 ]


I've just replaced all usages of TaglibFreeMarkerView with the regular FreeMarkerView in several of our real-world applications which heavily use the taglib functionality, and it seems to work just fine! Waiting for RC1 to deploy into production...


Comment by Nick Richards [ 13/Sep/06 ]

To quote Homer, "Holy Macaroni!". Integrating both Erik's and Tom's code gives me JspTaglibs access in my out of the box spring + freemarker setup. Thanks very much! (and to the rest of the Spring folks too!)

This JspTaglibs support really needs to be made a part of Spring, or made into a filter. Immediately after discovering the no-taglibs limitation with the out of the box Spring integration, I felt like I had to drop FreeMarker...that was a "deal breaker".

I opted to drop Tom's Views.properties and go with Erik's bean config xml. Here's mine:

<bean id="freemarkerConfig" class="org.springframework.web.servlet.view.freemarker.FreeMarkerConfigurer">
<property name="templateLoaderPath" value="/WEB-INF/ftl/"/>
<bean id="freemarkerServletContextModel"
<bean id="freemarkerTaglibFactory"
<bean id="viewResolver"
<property name="servletContextModel" ref="freemarkerServletContextModel" />
<property name="taglibFactory" ref="freemarkerTaglibFactory" />
<property name="cache" value="true" />
<property name="prefix" value="" />
<property name="suffix" value=".ftl" />
<property name="exposeSpringMacroHelpers"
value="true" />


Comment by Nick Richards [ 13/Sep/06 ]

FYI I am still on 1.2.6, not sure about jumping to 2.0, worried about destabilization.... Cheers.

Comment by Waldemar Baraldi [ 20/Feb/07 ]

I have started a new thread in the forum regarding an issue using this feature.


Generated at Sun May 20 23:31:34 UTC 2018 using JIRA 7.9.0#79000-sha1:3ca552e944c2fe83b21589bc06f155b9b428cc2b.