response.addheader?freemarker导出word文档,怎么写
一、asp.net如何把上传的文件下载下来
FileInfoinfo=newFileInfo(filePath)
;longfileSize=info.Length;Response.Clear()
;Response.ContentType="application/octet-stream"
;Response.AddHeader("Content-Disposition","attachement;filename="+fileName)
;//指定文件大小Response.AddHeader("Content-Length",fileSize.ToString())
;Response.WriteFile(filePath,0,fileSize)
;Response.Flush()
;Response.Close()
;filepath为你刚次上传的文件路径,fileName为文件名字,不懂可以再交流
二、freemarker导出word文档,怎么写
将要导出的Word另存为xml格式的文件,打开xml在其中添加freemarker标签,然后另存为outChairDoc.ftl文件.
第一步要加入Freemarker.jar包。
Servlet代码如下:在outChairDoc.ftl放在包cn.skyclass.jiaowu.freemarker.template下
publicvoiddoGet(HttpServletRequestrequest,HttpServletResponseresponse)
throwsServletException,IOException{
configuration=newConfiguration();
configuration.setDefaultEncoding("utf-8");
try{
createDoc(response);
}catch(Exceptione){
//TODOAuto-generatedcatchblock
e.printStackTrace();
}
}
publicvoidcreateDoc(HttpServletResponseresponse)throwsException{
//要填入模本的数据文件
MapdataMap=newHashMap();
dataMap.put("docTitle","fdfdfdfdfdfdf用户信息");
Listlist=newArrayList();
ChairInfochairInfo=newChairInfo();
chairInfo.setChairTitle("dfdfd");
chairInfo.setTeacherName("tea");
chairInfo.setStartTime(newDate());
chairInfo.setPlace("dfdfd");
list.add(chairInfo);
dataMap.put("chairInfoList",list);
//设置模本装置方法和路径,FreeMarker支持多种模板装载方法。可以重servlet,classpath,数据库装载,
//这里我们的模板是放在com.havenliu.document.template包下面
configuration.setClassForTemplateLoading(this.getClass(),
"/cn/skyclass/jiaowu/freemarker/template");
Templatet=null;
try{
//test.ftl为要装载的模板
t=configuration.getTemplate("outChairDoc.ftl");
t.setEncoding("utf-8");
}catch(IOExceptione){
e.printStackTrace();
}
//输出文档路径及名称
StringfileName="讲座列表.doc";
response.setContentType("application/msword");
response.addHeader("Content-Disposition","attachment;filename="+java.net.URLEncoder.encode(fileName,"UTF-8"));//可防止导出的文件乱码
response.setCharacterEncoding("utf-8");
PrintWriterout=response.getWriter();
t.process(dataMap,out);
out.close();
}
三、asp.net中怎么限制重复提交在线急等
让网页过期,或者不让网页被IE缓存1.禁止客户端缓存要在
中加入类似如下内):ASP.net代码如下:放在页面代码Page_OnloadHttpContext.Current.Response.Expires=0;Response.ExpiresAbsolute=DateTime.Now-1;Response.AddHeader("progma","no-cache");Response.AddHeader("cache-control","private");Response.CacheControl="no-cache";