*******************************************************
* Reprint Please specify source address Http://blog.csdn.net/csuliky Author: Abu
*******************************************************
First of all, we have a little bit of an understanding of Freemarker, in this chapter, we have to learn how to write a simple but very effective freemarker template.
1. Template + data Model = Output
Suppose one of yo
FreeMarker notes Chapter 4 others, freemarker Chapter 44.1 Introduction to custom commands 4.1.1
Custom commands can be defined using macro commands. If the Java programmer does not want to implement definition commands in the template, but implements the definition of commands in the Java language, the freemarker. template. TemplateDirectiveModel class can be us
FreeMarker concept introduction (1), freemarker concept Introduction1. What is FreeMarker?
It is a tool that generates text output based on templates and is written in java. It has nothing to do with specific containers and does not know HTTP or Servlet. Therefore, it can be applied in non-Web application environments. Just like a factory where raw materials (suc
FreeMarker learning and freemarker Learning
1. FreeMarker
FreeMarker is a template engine. It is a common tool based on templates and data to be changed and used to generate output text (HTML webpage, email, configuration file, source code, etc. It is not intended for end users, but a Java class library. It is a compon
FreeMarker generation page (3): freemarker generation page
This article introduces Freemarker's core functions, or what problems it can solve. In the first article, we mentioned that Freemarker is a template language. What is a template language.
I also searched for information on the Internet in a short time. The following is a blog I found about Java template
Freemarker replacement (square brackets) syntax, freemarker square bracketsNote:This feature is available only after FreeMarker 2.3.4.
FreeMarker supports a replacement syntax. [And] is used in the instructions and comments of FreeMarker to replace
Call predefined commands:
Getting started with freemarker Template Development, freemarker Template
Data Model
Scalars scalar: Specify its path from the root, separated by vertices.
For example: whatnot. fruits
Sequences sequence: Use square brackets of an array to access the subvariables of a sequence.
For example, animals [0]. name, whatnot. fruits [1]
Summary:
Data models can be viewed as tree structures.A scalar stores a single
Variables defined in the freemarker template and the freemarker Template
Three types of variables can be defined in the template:
Simple variable: it can be accessed from any location in the template, or from the template introduced using the include command. You can use the assign or macro commands to create or replace these variables.
Local variables: they can only be set in the macro definition body
Freemarker custom commands and freemarker commands
1 Overview
Custom commands can be defined using macro commands, which is a concern of template designers. Java programmers can use the freemarker. template. TemplateDirectiveModel class to extend the definition of commands in Java instead of implementing definition commands in templates.
2 Basic Content
The macr
FreeMarker notes Chapter 2 values and types, freemarker Chapter 22.1 Basic Content 2.1.1 Introduction 2.1.2 What is a value
It is similar to the numeric type in programming languages.2.1.3 what is a type? 2.1.4 the data model is hash table 2.2 type 2.2.1 introduction 2.2.2 scalar
Scalar is the most basic and simple numeric type. It can be a string, number, Boolean value, or date;2.2.3 container
The containe
eclipse install Freemarker plug-ins and FTL using Freemarker editor Online installation method is:help–> install New software click and http://download.jboss.org/jbosstools/updates/development/indigo/found under JBoss application development Freemarker IDE select in click Next Install and restart Eclipse to be able to do so. Install
eclipse install Freemarker plug-ins and FTL using Freemarker editor Online installation method is:help–> install New software click and http://download.jboss.org/jbosstools/updates/development/indigo/found under JBoss application development Freemarker IDE select in click Next Install to restart Eclipse . Copyright NOTICE: This article for
In the generation of Excel, most of the time is the use of POI,JXL, and so on, but for the complex of Excel, this workload is very large, and, for me so lazy people, it is rather painful one thing, so, I have to find out if there is a simple way to get this thing done. I thought about the last time I successfully generated a Word document with Freemarker. I was wondering if I could build Excel too? Then I'll try. The result is great, however, and ther
Definition: Freemarker is a template engine written in the Java language that generates text output based on a template. Freemarker is not related to the Web container, that is, it does not know the servlet or HTTP while the Web is running. It can be used not only as an implementation technique for the presentation layer, but also for generating xml,jsp or Java.Features: Universal, able to generate a variet
Date conversion in Freemarker and freemarker date conversion
1. Convert the date represented by the number type to the datetime type and output the string.$ {Item. time? Number_to_datetime}. The default format is "yyyy-MM-dd hh: mm: ss ".You can manually set the datetime format before calling, for example, 2. Convert the date represented by the date type to the string format and output the string.$ {Item. t
Freemarker has some special usage methods, such as freemarker.
Freemarker expressions are powerful, but they are complicated to use in some special cases, such as nesting. Here we will gradually accumulate some expressions for your use.
1. When struts2 is used, the static method of the execution class is defined as a variable, such:
Freemarker macro and function usage and difference, freemarker macro usage
1. macro (macro)Statement:
Introduction Method: Call method: 2. Functions)Statement:
Introduction Method: Call method: $ {buildPageUrl (url2, page. pageNum + 1, page )}3. Different PlacesMACRO: return in advance, for example, But not Macro, the main function is to splice the content and display the internal strings of the mac
Freemarker loads the template file, and freemarker loads the Template
Java code:
Public String getContent (String name, HashMap
// Home file path + name (Template File name) paramMap contains (parameter values of page parameters)String content = "";Try {ParamMap. put ("name", name );ParamMap. put ("templ", this );ParamMap. put ("param", paramMap );This. paramMap = paramMap;
Configuration configuration = ne
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.