Screen Development Using FreeMarker

This section explains screen development using FreeMarker(external site) .

The installation procedure of FreeMarker is as follows. For more information on the procedure, see FreeMarker document .

  1. Add FreeMarker to the dependant library
  2. Configure the FreeMarkerServlet settings
  3. Create a template file (ftl file) to implement an action
  4. Prevent duplicate form submission (only if necessary) Add FreeMarker to the dependant library

Add FreeMarker to dependent libraries to make it available to projects. When using Maven, add the following to POM. This manual has been confirmed with the version described in dependency below.

</dependency> Configure the FreeMarkerServlet settings

Register FreeMarkerServlet in web.xml and make it respond to *.ftl.

Example of web.xml


    Specify the placement directory of the template file (ftl).
    If "/" is specified, the root directory of war is used as the deployment directory.

    <!-- For other than the above, refer to the document and configure the required parameters -->
</servlet-mapping> Create a template file (ftl file) to implement an action

Create and place a template file (ftl file). (For how to create a template, refer to the FreeMarker documentation) Action class returns the path to the template file as a response.

For example, to return HTML to the client using webapp/WEB-INF/template/index.ftl, action class returns the response as shown below. (webapp is the root directory of war)

return new HttpResponse("/WEB-INF/template/index.ftl");


The mechanism to return the HTML generated by FreeMarker to the client is as follows.

  1. HTTP Response Handler performs Servlet forward to /WEB-INF/template/index.ftl.
  2. In response to the ftl extension, FreeMarkerServlet is executed to generate HTML based on the template, request scope, and other data.
  3. Return the HTML that is generated to the client. Prevent double submission

To prevent double submission, create an action by referring to UseToken Interceptor.