There was a similar request on the FreeMarker lists a couple of days ago - I didn't know you could do that until I saw that post. The documentation for this is hidden at the bottom of the page on "using FreeMarker with servlets" on the FreeMarker site!
There's certainly no current support for this in Spring. It works using the FM servlet because their servlet creates its own custom taglib loader. It doesn't look as though it would be too difficult to add support for it to the Spring classes - some checking of variable scoping would be required (Page, Request, Session and Application) since Spring's FM support doesn't scope this way. Maybe it needs to.
If you needed support for this right now, the following may work (completely untested):
- 1. define the FreeMarker servlet in your web.xml and map it to *.ftl as recommended.
2. Set the TemplatePath init-param to be /WEB-INF/freemarker
3. declare a view resolver in your Spring context like so,
Code:
<bean
id="viewResolver"
class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass">
<value>org.springframework.web.servlet.view.InternalResourceView</value>
</property>
<property name="prefix"><value></value></property>
<property name="suffix"><value>.ftl</value></property>
</bean>
4. From your controller, return a view name of "foo" to load the template /WEB-INF/freemarker/foo.ftl
Templates loaded this way should be able to load the taglibs - I'll try to have a look at this today to see what's involved.
Let us know how you get on if you try this?
Darren Davison.
Public Key: 0xE855B3EA