Reputation: 5963
I wanted to know how, if possible, to use freemarker tag library in a jsp file. I am using the Struts2 framework. Currently I do not have the bandwidth to convert all the jsp files in my project in to ftl file, hence the conundrum.
I checked out http://freemarker.sourceforge.net/docs/pgui_misc_servlet.html#autoid_57 but it does not really say much.
Upvotes: 2
Views: 3086
Reputation: 1294
I found the javadocs for this tag: http://freemarker.sourceforge.net/docs/api/freemarker/ext/jsp/FreemarkerTag.html But I really didn't find any examples using it. It should do the thing you're saying, I'm looking for the same thing.
Upvotes: 0
Reputation: 319
We have been doing the same thing where I work and we've created a custom taglib with tags for each of the templates we've put into our JSPs.
For example: We have productSpecs.ftl that is replacing some content on a product page. We've created a taglib (named ftl) and are putting in our JSPs. We have done some Java magic so that we have a Java class for each tag in our taglib. In other words, there's a class called ProductSpecs.java that basically just loads the ftl file by the same name and combines it with our JSON data and writes the output in html.
There's a little more work than what I've detailed above, but my point is that it's totally possible.
Upvotes: 1
Reputation: 31122
You can't use FreeMarker directives (tags) in a JSP file (unless someone has written a JSP taglib for that, but I strongly doubt that). (FreeMarker templates can use JSP tags, with limitations, but that's not what you are asking.)
Upvotes: 0
Reputation: 7519
The Struts 2 tag library is implemented in JSP tags, Velocity tags, and Freemarker tags. The syntax is slightly different for each view layer technology, but it's all well documented.
http://struts.apache.org/2.x/docs/struts-tags.html
Upvotes: 1
Reputation: 23587
If you want to Free marker template in place of standard struts2 template than i believe framework provides an extension to this.
FreeMarker tags are extensions of the generic Struts Tags provided by the framework. You can jump right in just by knowing the generic structure in which the tags can be accessed: <@s.tag> ...</@s.tag>
, where tag is any of the tags supported by the framework.
For more details refer to the official doc.
Upvotes: 1