FreeMarker Template Tutorials, Tips & Tricks

FreeMarker is a Java-based template engine focusing on the MVC software architecture. Although it’s mostly used for Servlet-based Web Application development, it can be used for any other kind of text output, such as generating CSS, Java source code, etc. Unlike JSP, it is not dependent on the Servlet architecture or on HTTP. Thus it can be used for non-Web tasks as well. FreeMarker is Free software.

How to access Static Fields in Freemarker FTL

If you defined static fields in Java class and want to use the same in Freemarker (FTL) it is not possible to do so as FTL is not aware of Java objects during rendering. In order to make static fields available to FTL, we need to expose them. One way of exposing static Java fields to freemarker template is to use them through Model. But if ...

Struts2 + FreeMarker Tempalte (FTL) Integration example

Struts2 + FreeMarker Tempalte (FTL) Integration example
Welcome to Freemarker Tutorial Series. In previous post we created Spring MVC based Hello World Freemarker Template example. We learned few APIs of freemarker and also how to integrate it with Spring MVC based application. Following are the list of tutorials from Freemarker tutorial series. Today we will create a Struts2 based application that uses Freemarker FTL as view instead of JSP. This would give ...

Spring MVC + FreeMarker (FTL) Integration example

Spring MVC + FreeMarker (FTL) Integration example
Welcome to Freemarker Tutorial Series. In previous post we created Servlet based Hello World Freemarker Template example. We learned few APIs of freemarker and also how to integrate it with Servlet based application. Following are the list of tutorials from Freemarker tutorial series. Today we will create a Spring MVC based application that uses Freemarker FTL as view instead of JSP. This would give you ...

FreeMarker Servlet Tutorial with Example

FreeMarker Servlet Tutorial with Example
Welcome to Freemarker Tutorial Series. In previous post we created our first Hello World Freemarker Template example. We learned few APIs of freemarker and also how template file is loaded in Java and values are replaced. Following is the list of tutorials from Freemarker tutorial series. Today we will create a Servlet based application that uses Freemarker FTL as view instead of default JSP. ...

FreeMarker (FTL) Hello World Tutorial with Example

FreeMarker (FTL) Hello World Tutorial with Example
In our previous tutorial Introduction to FreeMarker Template, we saw basics and overview of FTL. Also some of its features and comparison with other view technologies such as Velocity and JSP. Following is the list of tutorials from Freemarker tutorial series. Today we will create our first Hello World FreeMarker application. To start with our app will be very basic. We define one ftl template ...

Introduction to FreeMarker Template (FTL)

Introduction to FreeMarker Template (FTL)
FreeMarker is a Java-based template engine focusing on the MVC software architecture. Although it's mostly used for Servlet-based Web Application development, it can be used for any other kind of text output, such as generating CSS, Java source code, etc. Unlike JSP, it is not dependent on the Servlet architecture or on HTTP. Thus it can ...

How To Iterate HashMap in FreeMarker (FTL)

In this short article we will see how to iterate an HashMap in FreeMarker template. Consider below code which is normally used to iterate a List in FTL. //Java List<String> cityList = new ArrayList<String>(); cityList.add("Washington DC"); cityList.add("Delhi"); cityList.add("Berlin"); cityList.add("Paris"); cityList.add("Rome"); request.setAttribute("cityList", cityList); //FTL template <#list cityList as city> <b> ${city} </b> </#list> Output: Here in above code, we created a List object and passed it to FTL page. In FTL we used ...