up:: FreeMarker的jar包下载引入
此处待叙述:
ftl文件,就是脚本啦!!!
对于FreeMarker,如有需要可以参考【指令 - FreeMarker 中文官方参考手册】,去查看FreeMarker的语法等内容;
一:FreeMarker:取值
FTL文件中如何取值
(1)输出一个不存在的值:!默认值
应该怎么做?
(2)时间的输出:时间需要?string格式化输出
应该怎么做?
使用?string进行格式化输出
(3)数字的格式化输出
(4)freemarker注释方式:<#— FreeMarker的注释 ⇒
(5)freemarker也可以获取JavaBean对象:
这儿定义了一个Javabean:Computer类:
package com.imooc.freemarker.entity;
import java.util.Date;
import java.util.Map;
public class Computer {
private String sn; // 序列号
private String model; // 型号
private int state; //电脑状态
private String user; //电脑使用者
private Date dop; //采购日期
private Float price; //价格
private Map info; //信息
public Computer() {}
public Computer(String sn, String model, int state, String user, Date dop, Float price, Map info) {
super();
this.sn = sn;
this.model = model;
this.state = state;
this.user = user;
this.dop = dop;
this.price = price;
this.info = info;
}
public String getSn() {
return sn;
}
public void setSn(String sn) {
this.sn = sn;
}
public String getModel() {
return model;
}
public void setModel(String model) {
this.model = model;
}
public int getState() {
return state;
}
public void setState(int state) {
this.state = state;
}
public String getUser() {
return user;
}
public void setUser(String user) {
this.user = user;
}
public Date getDop() {
return dop;
}
public void setDop(Date dop) {
this.dop = dop;
}
public Float getPrice() {
return price;
}
public void setPrice(Float price) {
this.price = price;
}
public Map getInfo() {
return info;
}
public void setInfo(Map info) {
this.info = info;
}
}