CINXE.COM

FreeMarker Java Template Engine

<!doctype html> <!-- Generated by FreeMarker/Docgen from DocBook --> <html lang="en" class="page-type-chapter"> <head prefix="og: http://ogp.me/ns#"> <meta charset="utf-8"> <title>FreeMarker Java Template Engine</title> <meta http-equiv="X-UA-Compatible" content="IE=edge"> <meta name="viewport" content="width=device-width,initial-scale=1"> <meta name="format-detection" content="telephone=no"> <meta property="og:site_name" content="Apache FreeMarker®"> <meta property="og:title" content="What is Apache FreeMarker®?"> <meta name="description" content="Java template engine; generates HTML web pages, e-mails, configuration files, source code, etc. from template files and the data your application provides."> <meta name="og:description" content="Java template engine; generates HTML web pages, e-mails, configuration files, source code, etc. from template files and the data your application provides."> <meta property="og:locale" content="en_US"> <meta property="og:url" content="https://freemarker.apache.org/index.html"> <link rel="canonical" href="https://freemarker.apache.org/index.html"> <link rel="icon" href="favicon.png" type="image/png"> <link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:500,700,400,300|Droid+Sans+Mono"> <link rel="stylesheet" type="text/css" href="docgen-resources/docgen.min.css?1741625416462"> <script type="text/javascript" src="https://cdn.jsdelivr.net/npm/cookie-bar/cookiebar-latest.min.js"></script> </head> <body itemscope itemtype="https://schema.org/Code"> <meta itemprop="url" content="https://freemarker.apache.org/"> <meta itemprop="name" content="Apache FreeMarker®"> <!--[if lte IE 9]> <div class="oldBrowserWarning" style="display: block"> Unsupported web browser - Use a modern browser to view this website! </div> <![endif]--> <div class="oldBrowserWarning"> Unsupported web browser - Use a modern browser to view this website! </div> <div class="header-top-bg"><div class="site-width header-top"><div id="hamburger-menu" role="button"></div> <div class="logo"> <a href="https://freemarker.apache.org/" role="banner"><img itemprop="image" src="logo.png" alt="FreeMarker"></a> </div> <ul class="tabs"><li class="current"><a href="index.html">Home</a></li><li><a href="docs/index.html">Manual</a></li><li><a class="external" href="docs/api/index.html">Java API</a></li></ul><ul class="secondary-tabs"><li><a class="tab icon-heart" href="contribute.html" title="Contribute"><span>Contribute</span></a></li><li><a class="tab icon-bug" href="https://issues.apache.org/jira/projects/FREEMARKER" title="Report a Bug"><span>Report a Bug</span></a></li><li><a class="tab icon-download" href="freemarkerdownload.html" title="Download"><span>Download</span></a></li></ul></div></div> <div class="main-content site-width"> <div class="content-wrapper"> <div id="table-of-contents-wrapper" class="col-left"> <script>var breadcrumb = ["Apache FreeMarker®","What is Apache FreeMarker®?"];</script> <script src="toc.js?1741625416462"></script> <script src="docgen-resources/main.min.js?1741625416462"></script> <div class="side-toc-logos"> <div class="side-toc-logo"> <a href="https://www.apache.org/events/current-event.html" target="_blank"><img src="https://www.apache.org/events/current-event-234x60.png" alt="Apache Incubator" /></a> </div> </div> </div> <div class="col-right"><div class="page-content"><div class="page-title"><div class="title-wrapper"> <h1 class="content-header header-chapter" id="what-is-freemarker" itemprop="headline">What is Apache FreeMarker®?</h1> </div></div><p>Apache FreeMarker® is a <em>template engine</em>: a Java library to generate text output (HTML web pages, e-mails, configuration files, source code, etc.) based on templates and changing data. Templates are written in the FreeMarker Template Language (FTL), which is a simple, specialized language (not a full-blown programming language like PHP). Usually, a general-purpose programming language (like Java) is used to prepare the data (issue database queries, do business calculations). Then, Apache FreeMarker displays that prepared data using templates. In the template you are focusing on how to present the data, and outside the template you are focusing on what data to present.</p><p class="center-img"> <img src="images/overview.png" alt="Figure"> </p> <p>This approach is often referred to as the MVC (Model View Controller) pattern, and is particularly popular for dynamic web pages. It helps in separating web page designers (HTML authors) from developers (Java programmers usually). Designers won&#39;t face complicated logic in templates, and can change the appearance of a page without programmers having to change or recompile code.</p><p>While FreeMarker was originally created for generating HTML pages in MVC web application frameworks, it isn&#39;t bound to servlets or HTML or anything web-related. It&#39;s used in non-web application environments as well.</p><p>See the <a href="docs/dgui_quickstart_basics.html">Manual for more details...</a></p> <h2 class="content-header header-simplesect" id="autoid_2">Features</h2> <p>A few highlights of FreeMarker:</p> <ul> <li> <p>Powerful template language: Conditional blocks, iterations, assignments, string and arithmetic operations and formatting, macros and functions, including other templates, escaping by default (optional), and many more</p> </li> <li> <p>Multipurpose and lightweight: Zero dependencies, any output format, can load templates from any place (pluggable), many configuration options</p> </li> <li> <p>Internationalization/localization-aware: Locale sensitive number and date/time formatting, localized template variations.</p> </li> <li> <p>XML processing capabilities: Drop XML DOM-s into the data-model and traverse them, or even process them declaratively</p> </li> <li> <p>Versatile data-model: Java objects are exposed to the template as a tree of variables through pluggable adapters, which decides how the template sees them.</p> </li> </ul> <h2 class="content-header header-simplesect" id="autoid_3">License</h2> <p>Apache FreeMarker is Free software, licensed under the Apache License, Version 2.0. <a href="docs/app_license.html">See the license here...</a>.</p> <p>Note that the project is owned by the Apache Software Foundation since 2.3.24-pre01 (2015-09-02). Earlier releases, such as 2.3.23, has a different copyright owner.</p> </div></div> </div> </div> <div class="site-footer"><div class="site-width"><div class="footer-top"><div class="col-left sitemap"><div class="column"><h3 class="column-header">Overview</h3><ul><li><a href="index.html">What is FreeMarker?</a></li><li><a href="freemarkerdownload.html">Download</a></li><li><a href="docs/app_versions.html">Version history</a></li><li><a href="docs/app_faq.html">FAQ</a></li><li><a itemprop="license" href="docs/app_license.html">License</a></li><li><a href="https://privacy.apache.org/policies/privacy-policy-public.html">Privacy policy</a></li></ul></div><div class="column"><h3 class="column-header">Often used / Reference</h3><ul><li><a href="https://try.freemarker.apache.org/">Try template online</a></li><li><a href="docs/dgui_template_exp.html#exp_cheatsheet">Expressions cheatsheet</a></li><li><a href="docs/ref_directive_alphaidx.html">#directives</a></li><li><a href="docs/ref_builtins_alphaidx.html">?built_ins</a></li><li><a href="docs/ref_specvar.html">.special_vars</a></li><li><a href="docs/api/freemarker/core/Configurable.html#setSetting-java.lang.String-java.lang.String-">Configuration settings</a></li></ul></div><div class="column"><h3 class="column-header">Community</h3><ul><li><a href="https://github.com/apache/freemarker">Github project page</a></li><li><a href="https://issues.apache.org/jira/projects/FREEMARKER">Report a bug</a></li><li><a href="report-security-vulnerabilities.html">Report security vulnerability</a></li><li><a href="https://stackoverflow.com/questions/ask?tags=freemarker">Get help on StackOverflow</a></li><li><a href="https://twitter.com/freemarker">Announcements on Twitter</a></li><li><a href="mailing-lists.html">Discuss on mailing lists</a></li></ul></div></div><div class="col-right"><ul class="social-icons"><li><a class="github" href="https://github.com/apache/freemarker">GitHub</a></li><li><a class="twitter" href="https://twitter.com/freemarker">Twitter</a></li><li><a class="stack-overflow" href="https://stackoverflow.com/questions/ask?tags=freemarker">Stack Overflow</a></li></ul><a class="xxe" href="http://www.xmlmind.com/xmleditor/" rel="nofollow" title="Edited with XMLMind XML Editor"><span>Edited with XMLMind XML Editor</span></a></div></div><div class="footer-bottom"> <p class="last-generated"> Last generated: <time itemprop="dateModified" datetime="2025-03-10T16:50:16Z" title="Monday, March 10, 2025 at 4:50:16 PM Greenwich Mean Time">2025-03-10 16:50:16 GMT</time> </p> <p class="copyright"> © <span itemprop="copyrightYear">1999</span>–2025 <a itemtype="http://schema.org/Organization" itemprop="copyrightHolder" href="http://apache.org/">The Apache Software Foundation</a>. Apache FreeMarker, FreeMarker, Apache, the Apache feather logo, and the Apache FreeMarker project logo are trademarks or registered trademarks of The Apache Software Foundation. All other marks mentioned may be trademarks or registered trademarks of their respective owners. </p> </div></div></div></body> </html>

Pages: 1 2 3 4 5 6 7 8 9 10