word模版,另存成test.xml,然后修改参数。将test.xml改为test.ftl.
然后用网上的这段代码生成word文档。打开时总是提示如下图(数据填入正确)
publicvoidcreateDoc(){
//要填入模本的数据文件
MapdataMap=newHashMap();
getData(dataMap);
//设置模本装置方法和路径,FreeMarker支持多种模板装载方法。可以重servlet,classpath,数据库装载,
//这里我们的模板是放在包下面
configuration.setClassForTemplateLoading(this.getClass(),"");
Templatet=null;
try{
//test.ftl为要装载的模板
t=configuration.getTemplate("test.ftl");
}catch(IOExceptione){
e.printStackTrace();//输出文档路径及名称
FileoutFile=newFile("D:/outFile.xml");
Writerout=null;
try{
out=newBufferedWriter(newOutputStreamWriter(newFileOutputStream(outFile)));
}catch(FileNotFoundExceptione1){
e1.printStackTrace();try{
t.process(dataMap,out);
}catch(TemplateExceptione){
e.printStackTrace();
}catch(IOExceptione){
e.printStackTrace();
}finallytry{
out.close();//释放流
}catch(IOExceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();}
freemarker的模板ftl文件是不是直接将html文件修改后缀为ftl就行了?
肯定不是了html是静态的freemarker的ftl是将html文件修改为动态的ftl模版
肯定支持的。
只跟你webserver上配置的freemarker有关,跟浏览器没有关系。
另外,站长团上有产品团购,便宜有保证
肯定支持的。
只跟你webserver上配置的freemarker有关,跟浏览器没有关系。
另外,虚机团上产品团购,超级便宜