---
title: "struts2文件下载图片和txt文件会在浏览器打开解决"
author: "daichangfu"
date: "2013-02-28T17:48:15Z"
tags: []
categories: ["企业架构"]
slug: "struts2-txt"
draft: false
lastmod: "2013-02-28T17:48:15Z"
id: 1818930
url: "https://daichangfu.iteye.com/blog/1818930"
---

```
	    	<result name="downLoad" type="stream">
	            <param name="contentType">${contentType}</param>
	            <param name="contentLength">${fileSize}</param>
	            <param name="inputName">inputStream</param>
	            <param name="contentDisposition">attachment;filename=${downFileName}</param>
	            <param name="bufferSize">4096</param>
            </result> 
```

 

```
<param name="contentDisposition">attachment;filename=${downFileName}</param>
<!-- attachment; filename前加上attachment就行了  -->
```