passer1991

jsp导出word


<%@ page contentType="application/vnd.ms-word; charset=utf-8"%>
<%@ page pageEncoding="utf-8"%>
 
<%  
    String fileName = "jsp导出word.doc";  
      //对中文文件名编码  
   //fileName = URLEncoder.encode(fileName, "utf-8");  
    byte[] yte = fileName.getBytes("GB2312");  
            String unicoStr = new String(yte, "ISO-8859-1");
   response.setHeader("Content-disposition", "attachment; filename=" + unicoStr);  
%>  
 
<html xmlns:v="urn:schemas-microsoft-com:vml"   
      xmlns:o="urn:schemas-microsoft-com:office:office"   
      xmlns:w="urn:schemas-microsoft-com:office:word"   
      xmlns:m="http://schemas.microsoft.com/office/2004/12/omml"   
      xmlns:st1="urn:schemas-microsoft-com:office:smarttags"   
      xmlns="http://www.w3.org/TR/REC-html40">  
<head>  
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">  
<meta name="ProgId" content="Word.Document">  
<meta name="Generator" content="Microsoft Word 12">  
<meta name="Originator" content="Microsoft Word 12">   
<title>JSP页面导出为Word文档</title>  
</head>  
<body>  
。。。页面内容。。。  
</body>  
</html> 

 


 http://blog.sina.com.cn/s/blog_59e2a4100100kejd.html

posted on 2013-04-01 16:30  passer1991  阅读(419)  评论(0编辑  收藏  举报

导航