源码如下:
public String exportCreditor() throws Exception{  
Map<String,Object> dataMap=new HashMap<String,Object>();
try { 
getCreditor(dataMap);  
        configuration.setDefaultEncoding("UTF-8"); 
        TemplateLoader templateLoader = new FileTemplateLoader(new File(PropertyUtil.getProperty("wordTemplatePath")));           
        configuration.setTemplateLoader(templateLoader);  
        Template t=configuration.getTemplate("workmodel3.ftl","UTF-8");  
        String filename = form.getCustomName()+"的债权转让协议"+(int) (Math.random() * 100000);
        File outFile = new File(PropertyUtil.getProperty("outTemplatePath")+filename+".doc");  
        Writer out = null;  
            out = new BufferedWriter(new OutputStreamWriter(new FileOutputStream(outFile)));  
            t.process(dataMap, out); 
           // Map<String, Object> msgParam = new HashMap<String, Object>();
String tempFilePath = "C:/tempFilePath/"+filename+".doc";
if (tempFilePath != null) {
dataMap.put("exportStatus", "1");
dataMap.put("message", "导出成功,请下载!");
dataMap.put("tempFilePath", tempFilePath);
} else {
dataMap.put("exportStatus", "0");
dataMap.put("message", "导出失败");
}
        } catch (Exception e) {
         dataMap.put("exportStatus", "0");
         dataMap.put("message", "导出失败");
logger.error(e.getMessage(), e);
e.printStackTrace();
}
FinancilUtil.setResponseByAjax(response, dataMap);
return null;  
       
    }  
在本机上测试导出的word是可以正常打开的,放到服务器上后也可以导出word,但是导出的word打不开,是“workmodel3.ftl”这个模板文件有问题,还是服务器有问题,搞得头都大了,请大神们帮我看看,谢谢啦!