Home  >  Article  >  Java  >  What is java template engine

What is java template engine

(*-*)浩
(*-*)浩Original
2019-05-21 19:38:056893browse

The template engine is generated to separate user pages and business data from each other. It will generate documents in a specific format from the data returned from the background. The template engine used for websites is to generate HTML documents.

What is java template engine

The template engine is mainly simple. Its main purpose is to allow program developers and art designers to have a clear division of labor; to reduce a lot of mechanical repetitive work in the code generation process. , greatly improving development efficiency, good design enables code reuse, and reduces later maintenance costs. The following aspects should be considered when using a good template engine: whether it is powerful, whether it is easy to use, integration, scalability and flexibility, and performance.

The following are commonly used java template engines:

  • XMLTemplate (referred to as XT)

  • Velocity (VT for short)

  • ##CommonTemplate(CT for short)

  • FreeMarker(FT for short)

  • Smarty4j (ST for short)

FreeMarker is a template engine: It is based on a template and the data to be changed, and is used to generate output text (HTML web pages, Email, configuration files, source code, etc.) It is not for end users, but a Java class library, a component that programmers can embed into the products they develop.

FreeMarker is free and released under the Apache License version 2.0. Its template is written in FreeMarker Template Language (FTL), which is a simple and dedicated language. Data needs to be prepared for display in real programming languages, such as database queries and business operations, and then the template displays the prepared data. In the template, it is mainly used for how to display data, while outside the template, focus on what data to display.

Velocity As a template engine with a long history, it can not only replace JSP as the server-side web page template engine of Java Web, but also can be used as a template engine for ordinary text to enhance the text processing capabilities of server-side programs. . Moreover, Velocity has been ported to different platforms, such as .Net's NVelocity and js's Velocity.js. Although the usage and implementation of each platform are slightly different, most of the syntax and engine core implementation are consistent, so the learning cost is A lot lower.

Related learning recommendations:

java basic tutorial

The above is the detailed content of What is java template engine. For more information, please follow other related articles on the PHP Chinese website!

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn