利用FreeMarker生成java源代码

Java培训:自定义代码生成器 需求:遍历学生集合,显示集合总条数,id不要逗号隔开,显示学生的生日(只显示年月日),钱包显示整数并显示单位`元`,用户姓名做脱敏处理(如果是两个字第二个字显示为星号,例如张三显示为`张*`,如果大于两个字,中间字显示为星号,例如成吉思汗显示为`成*汗`,诸葛亮显示为`诸*亮`)在代码中可以由JDBC的Connection对象通过getMetaData方法获取而来,主要封装了是对数据库本身的一些整体综合信息,例如数据库的产品名称,数据库的版本号,数据库的URL,是否支持事务等等。存着其他数据库的信息。 阅读详情

一 FreeMarker简介

Apache FreeMarker是一个Java模板引擎库,官网:http://freemarker.incubator.apache.org/。

Apache FreeMarker is a template engine: 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). 
You meant to prepare the data to display in a real programming 
language, like issue database queries and do business calculations, 
and then the template displays that already prepared data. In the 
template you are focusing on how to present the data, and outside the 
template you are focusing on what data to present.

这里写图片描述

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 the Web page designers (HTML authors) from the 
developers (Java programmers usually). Designers won’t face 
complicated logic in templates, and can change the appearance of a 
page without programmers having to change or recompile code.

While FreeMarker was originally created for generating HTML pages in 
MVC web application frameworks, it isn’t bound to servlets or HTML or 
anything Web-related. It’s used in non-web application environments as 
well.

模板就是把共性(固定不变的)的东西提取出来反复使用,节约时间 提高开发效率。现在主流的模板技术包括:FreeMarker和Velocity,模板技术推崇一种模式:输出=模板+数据。 
FreeMarker最开始被MVC Web框架用来生成HTML页面,但它的用途不仅限于HTML或者Web领域,比如本文所要介绍的生成JavaBean源代码。

二 生成JavaBean源代码

本文中将使用Freemarker 生成Person.java类代码,如下:

package com.ricky.java;

import java.util.List;

/**
 *  @author Ricky Fung
 */
public class Person {
    private Long id;
    private String name;
    private Integer age;
    private List<String> hobby;

    public void setId(Long id){
        this.id = id;
    }
    public Long getId(){
        return this.id;
    }

    public void setName(String name){
        this.name = name;
    }
    public String getName(){
        return this.name;
    }

    public void setAge(Integer age){
        this.age = age;
    }
    public Integer getAge(){
        return this.age;
    }

    public void setHobby(List<String> hobby){
        this.hobby = hobby;
    }
    public List<String> getHobby(){
        return this.hobby;
    }

}

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 24
  • 25
  • 26
  • 27
  • 28
  • 29
  • 30
  • 31
  • 32
  • 33
  • 34
  • 35
  • 36
  • 37
  • 38
  • 39
  • 40
  • 41
  • 42
  • 43

2.1 引入Freemarker 依赖

<dependency>
            <groupId>org.freemarker</groupId>
            <artifactId>freemarker</artifactId>
            <version>2.3.23</version>
        </dependency>
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 1
  • 2
  • 3
  • 4
  • 5

2.2 Freemarker 模板文件 person.ftl

package ${packageName};

import java.util.List;

/**
 *  @author ${author}
 */
public class ${className} {
    <#list attrs as attr> 
    private ${attr.type} ${attr.name};
    </#list>

    <#list attrs as attr>
    public void set${attr.name?cap_first}(${attr.type} ${attr.name}){
        this.${attr.name} = ${attr.name};
    }
    public ${attr.type} get${attr.name?cap_first}(){
        return this.${attr.name};
    }

    </#list>
}

 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 14
  • 15
  • 16
  • 17
  • 18
  • 19
  • 20
  • 21
  • 22
  • 23

2.3 Create a configuration instance

Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
        cfg.setDirectoryForTemplateLoading(templateDir);    
        cfg.setDefaultEncoding("UTF-8");
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);
 
  • 1
  • 2
  • 3
  • 4
  • 1
  • 2
  • 3
  • 4

2.4 Create a data-model 
1)In simple cases you can build data-models using java.lang and java.util classes and custom JavaBeans:

  • Use java.lang.String for strings.
  • Use java.lang.Number descents for numbers.
  • Use java.lang.Boolean for boolean values.
  • Use java.util.List or Java arrays for sequences.
  • Use java.util.Map for hashes.
  • Use your custom bean class for hashes where the items correspond to 
    the bean properties. For example the price property (getProperty()) 
    of product can be get as product.price. (The actions of the beans can 
    be exposed as well; see much later here)

2)代码构建数据模型

Map<String, Object> root = new HashMap<String, Object>();

        root.put("packageName", "com.ricky.java");
        root.put("className", "Person");
        root.put("author", "Ricky Fung");

        List<Attribute> attr_list = new ArrayList<Attribute>();
        attr_list.add(new Attribute("id", "Long"));
        attr_list.add(new Attribute("name", "String"));
        attr_list.add(new Attribute("age", "Integer"));
        attr_list.add(new Attribute("hobby", "List<String>"));

        root.put("attrs", attr_list);
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 11
  • 12
  • 13

2.5 获取指定模板

Template temp = cfg.getTemplate("person.ftl");
 
  • 1
  • 1

此时,会在E:/Work/Freemarker/templates目录下查找person.ftl。

2.6 用数据渲染模板

Writer out = new OutputStreamWriter(System.out);
temp.process(root, out);
 
  • 1
  • 2
  • 1
  • 2

如果需要将结果序列化到硬盘上,可以使用下面代码:

File dir = new File("E:/Work/Freemarker/src/");
        if(!dir.exists()){
            dir.mkdirs();
        }
        OutputStream fos = new  FileOutputStream( new File(dir, "Person.java")); //java文件的生成目录   
        Writer out = new OutputStreamWriter(fos);
        temp.process(root, out);

        fos.flush();  
        fos.close();
 
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10
  • 1
  • 2
  • 3
  • 4
  • 5
  • 6
  • 7
  • 8
  • 9
  • 10

最后,贴上CodeGenerator.java完整的代码

package com.ricky.spring.springdemo.freemarker;

import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.OutputStream;
import java.io.OutputStreamWriter;
import java.io.Writer;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import freemarker.template.Configuration;
import freemarker.template.Template;
import freemarker.template.TemplateException;
import freemarker.template.TemplateExceptionHandler;

public class CodeGenerator {

    public static void main(String[] args) {

        try {
            new CodeGenerator().gen();
        } catch (IOException e) {
            e.printStackTrace();
        } catch (TemplateException e) {
            e.printStackTrace();
        }
    }

    public void gen() throws IOException, TemplateException{

        Configuration cfg = new Configuration(Configuration.VERSION_2_3_22);
        cfg.setDirectoryForTemplateLoading(new File("E:/Work/Freemarker/templates"));   
        cfg.setDefaultEncoding("UTF-8");
        cfg.setTemplateExceptionHandler(TemplateExceptionHandler.RETHROW_HANDLER);

        Template temp = cfg.getTemplate("person.ftl");  // load E:/Work/Freemarker/templates/person.ftl

        // Create the root hash
        Map<String, Object> root = new HashMap<String, Object>();

        root.put("packageName", "com.ricky.java");
        root.put("className", "Person");
        root.put("author", "Ricky Fung");

        List<Attribute> attr_list = new ArrayList<Attribute>();
        attr_list.add(new Attribute("id", "Long"));
        attr_list.add(new Attribute("name", "String"));
        attr_list.add(new Attribute("age", "Integer"));
        attr_list.add(new Attribute("hobby", "List<String>"));

        root.put("attrs", attr_list);

//      Writer out = new OutputStreamWriter(System.out);
//      Writer out = new OutputStreamWriter(System.out);
        File dir = new File("E:/Work/Freemarker/src/");
        if(!dir.exists()){
            dir.mkdirs();
        }
        OutputStream fos = new  FileOutputStream( new File(dir, "Person.java")); //java文件的生成目录   
        Writer out = new OutputStreamWriter(fos);
        temp.process(root, out);

        fos.flush();  
        fos.close();

        System.out.println("gen code success!");
    }
}




官网的一并拿来:URL:http://freemarker.org/



 

What is Apache FreeMarker?

Apache FreeMarker is a template engine: 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). You meant to prepare the data to display in a real programming language, like issue database queries and do business calculations, and then the template displays that already prepared data. In the template you are focusing on how to present the data, and outside the template you are focusing on what data to present.

Figure

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't face complicated logic in templates, and can change the appearance of a page without programmers having to change or recompile code.

While FreeMarker was originally created for generating HTML pages in MVC web application frameworks, it isn't bound to servlets or HTML or anything web-related. It's used in non-web application environments as well.

See the Manual for more details...

Disclaimer: Apache FreeMarker is an effort undergoing incubation at The Apache Software Foundation (ASF), sponsored by the Apache Incubator. Incubation is required of all newly accepted projects until a further review indicates that the infrastructure, communications, and decision making process have stabilized in a manner consistent with other successful ASF projects. While incubation status is not necessarily a reflection of the completeness or stability of the code, it does indicate that the project has yet to be fully endorsed by the ASF.

Features

A few highlights of FreeMarker:

  • 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

  • Multipurpose and lightweight: Zero dependencies, any output format, can load templates from any place (pluggable), many configuration options

  • Internationalization/localization-aware: Locale sensitive number and date/time formatting, localized template variations.

  • XML processing capabilities: Drop XML DOM-s into the data-model and traverse them, or even process them declaratively

  • 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.

License

FreeMarker is Free software, licensed under the Apache License, Version 2.0. See the license here....

As of 2.3.24-pre01 (2015-09-02) the copyright owner in the license has changed to the Apache Software Foundation, as the project has started Apache Incubation (see disclaimer earlier).

部分转自:http://blog.youkuaiyun.com/top_code/article/details/50380825
FreeMarker 生成Java、mybatis文件 FreeMarker 生成Java、mybatis文件 将mysql数据库表通过FreeMarker生成对应的Java文件和对应的mybatis文件。 FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据,并用来生成输出文本(HTML网页、电子邮件、... 阅读详情

相关推荐

freemarker+itext生成PDF文件

介绍 FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页、电子邮件、配置文件、源代码等)的通用工具。 它不是面向最终用户的,而是一个Java类库,是一款程序员可以嵌入他们所开发产品的组件。 iText是一种生成PDF报表的Java组件。通过在服务器端使用Jsp或JavaBean生成PDF报表,客户端采用超链接显示或下载得到生成的报表,这样就...

破茧成蝶 3722

使用FreeMarker生成代码

pom.xml // 引入FreeMarker包。Test.ftl // 指定的模板引擎。Main.java // 生成代码封装。

focus-unchanged-thing 1622

用Python写个彩票小助手:自动生成双色球/大乐透号码并保存到桌面

本文介绍如何使用Python开发一个智能彩票助手,实现双色球和大乐透号码的随机生成与桌面文件保存功能。通过详细的代码示例,包括随机号码生成、文件操作、用户交互和错误处理,帮助Python初学者快速掌握实用工具开发技巧。

weixin_42566121的博客 521

springboot+freemarker手撸一个代码自动生成器!!

手撸一个代码自动生成器!! 实现功能:MyBatis 逆向工程 技术架构 页面是用 Vue ,element-ui开发;网络请求是 Axios。 服务端是 Spring Boot 页面模版是 Freemarker: 开发步骤: 一、创建工程 二、数据库连接操作 1.所需包结构 2.在model包中创建Db类 作用:用于接受前端传来数据库连接相关的值(username,password,url) package com.example.generate_code.model; /** * @au

Javaer 4827

Windows非分页缓冲池内存泄漏实战:PoolMon与RAMMap高效排查指南

本文详细介绍了Windows系统中非分页缓冲池内存泄漏的实战排查方法。当系统出现卡顿且内存占用异常增长时,通过RAMMap工具快速定位非分页缓冲池异常,并利用PoolMon监控内核内存分配标签,精准锁定泄漏源。文章提供了从确认症状、安装工具到使用findstr命令溯源驱动文件的完整五步排查流程,并总结了常见泄漏标签与解决方案,帮助用户高效解决深层系统内存问题。

weixin_28455801的博客 1012

极具性价比的步进电机驱动芯片-TMC2226/TMC2209使用小结

TMC2226/2209相对于TMC2660C、TMC5160来说,价格低了很多,同时功能并没有太多阉割。对比TMC5160,少了内部加减速曲线,电流足够(Ipeak = 2.8A),相对5160而言功能也很足够,所以毫无疑问TMC2226是极具性价比的步进驱动芯片。

Trinamic_TMC的博客 7016

freemarker 生成 Java 代码

一、导入maven依赖 <project xmlns=" xmlns:xsi=" xsi:schemaLocation=" <modelVersion>4.0.0</modelVersion> <groupId>cn.test</groupId> <artifactId>freemarket</artifactId> <version>0.0.1-SNAPSHOT</version...

wubaohu1314的博客 1353

保姆级教程:用YOLOv5+ROS2 Humble搞定奥比中光Dabai DCW深度相机的3D物体定位

本教程详细介绍了如何使用YOLOv5模型和ROS2 Humble系统,结合奥比中光Dabai DCW深度相机实现3D物体定位。从环境配置、模型部署到深度数据融合,提供完整的实战指南,帮助开发者快速掌握三维坐标提取技术,适用于机器人开发和计算机视觉应用。

weixin_26765363的博客 270

freemarker 生成java_freemarker代码生成

代码生成用一事例讲解代码生成1. 首先写一个类,如TitanPluginExporter 让其继承GenericExporter类。在该类中有一个init方法,该方法的作用是设置模板的路径和生成文件的类型。public class TitanPluginExporter extends GenericExporter {protected void setupContext() {super.se...

weixin_35714577的博客 520

Valgrind 从入门到精通:内存调试和性能分析

Valgrind 提供了强大的 API,允许开发者编写自定义的检查工具。通过扩展 Valgrind,可以针对特定场景实现更精准的检测。

大模型大数据攻城狮的专栏 1218

【OpenClaw从入门到精通】第02篇:5分钟速通!阿里云/华为云一键部署OpenClaw(附避坑指南·2026实测版)

本文聚焦OpenClaw的云端部署场景,针对本地部署“关机即离线、跨设备访问难”的痛点,详解阿里云(主推)和华为云(备选)的一键部署流程。2026实测验证:阿里云轻量应用服务器通过官方OpenClaw镜像可5分钟完成部署,华为云Flexus L实例需补充SSH配置步骤;文中拆解云端部署核心概念(地域选择、端口放行、成本构成),通过“AI助理定时抓取行业资讯并推送钉钉”的虚拟案例演示云端7×24小时运行价值,同时提供模型调用、服务器成本的精细化控制方案,梳理端口访问失败、API-Key权限异常等高频坑点的解决

专注于人工智能、软件开发、工控自动化、工厂数字化及智能化等领域,希望和大家共同进步! 5551

freemarker生成java代码_freeMarker之根据模板生成JAVA代码示例

首先导入maven依赖:org.freemarkerfreemarker2.3.28之后新建包,并在该包下编写模板文件test.ftl:package ${classPath};public class ${className} {private Integer ${Id};private String ${userName};private String ${passWord};public I...

weixin_34207964的博客 317

信号的反射(振铃、台阶、回勾、尖峰毛刺)

反射是怎么形成的 假设信号传输过程中,经过两个阻抗不同的区域,如下图所示。区域1阻抗为Z1,区域2阻抗为Z2。 在分界面处,电压必须是连续的,否则,在分界面处会产生无穷大的电场,这在真实世界中是不可能的。 同样,分界面两侧的电流必须是连续的,否则分界面处会产生无穷大的磁场。 因此: 根据欧姆定律,必然有: 显然如果Z1≠Z2的情况下,上面式子不可能同时成立。如何理解这一困境? 应该从 ...

sinat_15677011的博客 1万+

用Java生成数据类

Kotlin具有简洁的语法来声明数据类: data class User(val name: String, val age: Int) 等&#25928...

专业的开发者“讨论” 343

openmediavault(OMV)(30)插件介绍(3)filebrowser文件管理器

filebrowser可以对omv的文件进行图形化管理,而不需要每次都通过命令进行修改。filebrowser安装。

Monster✺◟(∗❛ัᴗ❛ั∗)◞✺的博客 2321

STM32F407中文手册

STM32f407中文手册 本参考手册面向应用开发人员,提供有关使用 STM32F405xx/07xx、STM32F415xx/17xx、 STM32F42xxx 和 STM32F43xxx 微控制器存储器与外设的完整信息。STM32F405xx/07xx、STM32F415xx/17xx、STM32F42xxx 和 STM32F43xxx 构成一个微 控制器系列,各产品具有不同的存储器大小、封装和外设。有关订购信息以及器件的机械与电气特性,请参见数据手册。有关 ARM Cortex™-M4F 内核的信息,请参见《Cortex™-M4F 技术参考手册》。

FreeMarker使用归纳

一般用来做界面 配置文件 还可以生成源代码(xml jsp也可以)比jsp运行效率高(因为不需要转换成java到class 是直接对模版进行解析 解析差值 把值插入然后返回页面数据) springMVC使用时候需要的两个配置 将FreeMarkerViewResolver 放在InteralResourceViewResolver前面(order是0优先级最高 InteralResourceVie...

weixin_40695328的博客 234

lwip-2.0.3

lwip是瑞典计算机科学院(SICS)的Adam Dunkels 开发的一个小型开源的TCP/IP协议栈。实现的重点是在保持TCP协议主要功能的基础上减少对RAM 的占用。

java生成pdf盖章合同_Java中使用 FreeMarker 生成pdf盖章合同文件

【实例简介】1.html模板+model数据,通过freemarker进行渲染,便于维护和修改2.渲染后的html流,可通过Flying Saucer组件生成pdf文件流,或者生成pdf后再转成jpg文件流【实例截图】【核心代码】java_pdf├── java_pdf│ ├── pom.xml│ ├── README.md│ ├── src│ │ └── main│ │...

weixin_39968410的博客 785

TMS_WebGMaps_1.9.8.0_Full_Source

TMS_WebGMaps_1.9.8.0_Full_Source 全源码 delphi cbuilder

迈瑞BS系列全自动生化分析仪LIS协议接口手册(内含HL7和ASTM)

迈瑞BS系列全自动生化分析仪LIS协议接口手册,内含HL7和ASTM)

Velocity和Freemarker模板牛刀小试(java)

Velocity是一个基于java的模板引擎(template engine)。它允许任何人仅仅简单的使用模板语言(template language)来引用由java代码定义的对象。当Velocity应用于web开发时,界面设计人员可以和java程序开发人员同步开发一个遵循MVC架构的web站点,也就是说,页面设计人员可以只关注页面的显示效果,而由java程序开发人员关注业务逻辑编码。Velocity将java代码从web页面中分离出来,这样为web站点的长期维护提供了便利,同时也为我们在JSP和PHP之

Ibex-Relieved的专栏 4307

Java泛型之mybatis,基于spring MVC 和 MyBatis 泛型的代码生成模板

原标题:基于spring MVC 和 MyBatis 泛型的代码生成模板简单说明这块代码生成工具是我抽空的时候方便自己使用而编写的,并不适合其他框架,这里由于项目原有,我并没有上传泛型部份的代码,这套代码是基于 spring Mvc + MyBatis 的,好了 废话不多说看图 我在这里主要贴出 java 部份的代码,源代码我已经上传 在文章底部我会贴出下载地址链接TableHandle.java...

weixin_32147807的博客 286

Java实现生成bean并编译打包成jar

生成bean核心代码块。二、编译并打包成jar。shell.sh脚本。

qq_34254462的博客 493

javacompiler编译java文件_java-compiler-api – 使用Java Compiler API编译多个java文件

我能够通过编译所有java文件来解决这个问题.使用FTL我生成java类,然后使用java编译器api编译它,并使用自定义类加载器加载类Java Complierprivate void compile(File[] files) throws IOException{String classpath=System.getProperty("java.class.path");String ro...

weixin_27017211的博客 416

Java项目中利用Freemarker模板引擎导出--生成Word文档

应邀写的一篇文章:Java项目中利用Freemarker模板引擎导出--生成Word文档 在项目中难免和各种数据报表打交道,如导出XX申请表,登记表,推荐表之类。就可以通过现有信息导出Word文档。基于Java语言来导出Word文档的方式也有很多种,如Jacob,Apache POI,Freemarker,PageOffice,java2word 等等。。。。 在这里将通过Freemarker这个模板引擎来实现导出 Word,项目不限于Swing,SSH,SSM,Spring Boot 之类的。。。。。。。

CJCC白朴的博客 1万+

使用模版引擎FreeMarker生成sql脚本

模版引擎FreeMarker生成sql脚本技术说明使用场景实现效果具体实现springboot引入依赖代码实现小结 技术说明 FreeMarker模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页,电子邮件,配置文件,源代码等)的通用工具。 它不是面向最终用户的,而是一个Java类库,是一款程序员可以嵌入他们所开发产品的组件(主要应用于生成HTML,使用过springbo...

weixin_39172079的博客 4593

Java实现freemarker生成word模板

博主在做的是将word源文件中的内容读取出来,然后按照固定的格式输出,当然,源文件有大量,所以编写了程序来批量自动生成目标文件。         本文要介绍的就是如何生成模板,并将从源文件截取的内容填充到模板文件(即生成目标文件)的过程,读取源文件内容的方法请阅读博主另一篇文章《Java实现poi方式读取word文件内容》。 1.准备工作         jar包----------free

长风破晓 1929

springboot项目中利用Freemarker模板生成word文档-包含表格和图片

标题因项目需要导出word报告,就研究了一下java生成word,网上的文章无非就是那几种方式,最简单的还是使用Freemarker的模板导出word,下面简单介绍使用方法: Freemarker介绍: FreeMarker是一款模板引擎: 即一种基于模板和要改变的数据, 并用来生成输出文本(HTML网页、电子邮件、配置文件、源代码等)的通用工具。 它不是面向最终用户的,而是一个Java类库,是一款程序员可以嵌入他们所开发产品的组件。 FreeMarker是免费的,基于Apache许可证2.0版本发布。其模

渝小白的博客 3088
上一篇: 一个java代码生成器的简单实现
下一篇: spring定时任务详解(@Scheduled注解)
ExceptionMapping
博客等级 码龄10年 30粉丝 11原创
评论
成就一亿技术人!
拼手气红包6.0元
还能输入1000个字符
 
 条评论被折叠 查看
添加红包

请填写红包祝福语或标题

个

红包个数最小为10个

元

红包金额最低5元

当前余额3.43元 前往充值 >
需支付:10.00元
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付元
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值