Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.
Comment: Migrated to Confluence 5.3

...

Getting started with FreeMarker is as simple as ensuring all the dependencies are included in your project's classpath. Typically, the only dependency is freemarker.jar. Other than that, struts-default.xml already configures the FreeMarker Result needed to process your application's templates.

Code Block
xml
xml
titlestruts.xmlxml
<action name="test" class="com.acme.TestAction">
    <result name="success" type="freemarker">test-success.ftl</result>
</action>

Then in test-success.ftl:

Code Block
xml
xml
titletest-success.ftlxml
<html>
<head>
    <title>Hello</title>
</head>
<body>

Hello, ${name}

</body>
</html>

...

Where mytag.tld is the JSP Tag Library Definition file for your tag library. Note: in order to use this support in FreeMarker, you must enable the JSPSupportServlet in web.xml:

Code Block
xml
xml
titleAdding JspSupportSerlvet to web.xmlxml
<servlet>
    <servlet-name>JspSupportServlet</servlet-name>
    <servlet-class>org.apache.struts2.views.JspSupportServlet</servlet-class>
    <load-on-startup>1</load-on-startup>
</servlet>

...