所以我有以下 FreeMarker 模板:
<?xml version="1.0" encoding="ISO-8859-1"?>
<master>
<header>
<version>${version}</version>
<created>${created}</created>
<creator>${creator}</creator>
<draw>${draw}</draw>
<game>${game}</game>
<type>${type}</type>
<sender>${sender}</sender>
<recipient>${recipient}</recipient>
<revision>${revision}</revision>
</header>
<data>
<stake>
${stake}
</stake>
<checksum_combifile>
${checksumFile}
</checksum_combifile>
</data>
</master>
一切都很好,一切都很甜蜜,但现在我想做以下事情,避免重复,因为我有许多具有相同标题结构的模板,将属于标题的变量移动到名为TemplateHeader的新类,如下所示:
public class TemplateHeader {
/* Header */
private String version;
private String created;
private String creator;
private String draw;
private String game;
private String type;
private String sender;
private String recipient;
private String revision;
public TemplateHeader() {
super();
}
public TemplateHeader(String version, String created, String creator, String draw, String game, String type, String sender, String recipient, String revision) {
super();
this.version = version;
this.created = created;
this.creator = creator;
this.draw = draw;
this.game = game;
this.type = type;
this.sender = sender;
this.recipient = recipient;
this.revision = revision;
}
public String getVersion() {
return version;
}
public void setVersion(String version) {
this.version = version;
}
public String getCreated() {
return created;
}
public void setCreated(String created) {
this.created = created;
}
public String getCreator() {
return creator;
}
public void setCreator(String creator) {
this.creator = creator;
}
但是我不知道该怎么做,因为我从 FreeTemplate 收到错误,并且在网上找不到任何教程....
相关分类