飙血推荐
  • HTML教程
  • MySQL教程
  • JavaScript基础教程
  • php入门教程
  • JavaScript正则表达式运用
  • Excel函数教程
  • UEditor使用文档
  • AngularJS教程
  • ThinkPHP5.0教程

springmvc文件下载

时间:2021-12-14  作者:匿名  
@RequestMapping("/download")  
	public void download(HttpServletResponse res ,HttpServletRequest req) throws IOException {  
	    OutputStream os = 域名utputStream();  
	    try {  
	        域名t();  
	        域名eader("Content-Disposition", "attachment; filename=域名");  
	        域名ontentType("application/octet-stream; charset=utf-8");  
	        域名e(域名FileToByteArray(getDictionaryFile(req)));  
	        域名h();  
	    } finally {  
	        if (os != null) {  
	            域名e();  
	        }  
	    }  
	}  
	
	 private File getDictionaryFile(HttpServletRequest req) {
		File file =new File(域名ession().getServletContext().getRealPath("/WEB-INF/域名"));
		return file;
	}

http://域名/topic/1125784

标签:文件JAVA
湘ICP备14001474号-3  投诉建议:234161800@qq.com   部分内容来源于网络,如有侵权,请联系删除。