public String TiKuWord() throws Exception{
System.out.println("aa"+aa);
listzujuan=ses.FindzuJuan(aa);
//listzujuan=ses.FindLianxi(aa);
//System.out.println(listzujuan.get(0).getShtitle());
Configuration configuration = newConfiguration();
configuration.setDefaultEncoding("utf-8");
// 模板放在com.canyou.template包下面,通过classpath装载
configuration.setClassForTemplateLoading(Tb_sc_selectAction.class,
"/com/ecsystem/action");
String zuzhuangcjr=(String) ActionContext.getContext().getSession().get("user");
Template t =configuration.getTemplate("yyyy"+".ftl");// 设置要装载的模板
String path =ServletActionContext.getServletContext().getRealPath("/paper");
File file = new File(path);
if(!file.exists()) {
file.mkdirs();
}
long d=(new Date()).getTime();
path=path+"\\"+zuzhuangcjr+d+".doc";
File outFile = new File(path);
if (!outFile.exists()) {
outFile.createNewFile();
}
Writer out = new BufferedWriter(newOutputStreamWriter(
new FileOutputStream(outFile),"utf-8"));
Map map = new HashMap<String,Object>();
map.put("rows", listzujuan);
if(listzujuan!=null &&listzujuan.size()>0){
map.put("titless",aa);
}
t.process(map, out);
ActionContext.getContext().getSession().put("daochu","导出成功");
ActionContext.getContext().put("daochu1","http://218.69.93.91:8090/ECSystem/paper/"+zuzhuangcjr+d+".doc");
ActionContext.getContext().put("daochu2","点击下载");
return SUCCESS;
}
/**
* 注意:在下载的时候必须使用流的形式将其输出,注意文件的路径获取,
*/
File file = newFile("/"+downloadDir.trim()+"/" + d);
InputStream is = newFileInputStream(file); //以流的形式输出文件信息
return is;
<script type="text/javascript"> function bao(s){ if(s=="选择题"){ document.getElementById("xzta").style.display=''; document.getElementById("xztb").style.display=''; document.getElementById("xztc").style.display=''; document.getElementById("xztd").style.display=''; var selectA = $.trim($("#selectA").val()); var selectB = $.trim($("#selectB").val()); var selectC = $.trim($("#selectC").val());
|