admin管理员组

文章数量:1533856

后端代码如下:需要注意的是头的设置,需要告诉浏览器需要下载文件,以及下载文件名。

在这里我下载的是一个docx文件

 /**
    * 导出
    * @param aFileName
    * @param aFilePath
    */
   public void doExport(String aFileName, String aFilePath,HttpServletRequest request, HttpServletResponse response){
	   BufferedInputStream bis = null;
       BufferedOutputStream bos = null;
       File file = null;
       file = new File(aFilePath);
       try{
	       request.setCharacterEncoding("UTF-8");
	       String agent = request.getHeader("User-Agent").toUpperCase();
	       if ((agent.indexOf("MSIE") > 0) || ((agent.indexOf("RV") != -1) && (agent.indexOf("FIREFOX") == -1)))
	           aFileName = URLEncoder.encode(aFileName, "UTF-8");
	       else {
	    	   aFileName = new String(aFileName.getBytes("UTF-8"), "ISO8859-1");
	       }
	       response.setConten

本文标签: 浏览器文件Javadocx