`

struts2 文件下载

阅读更多
1 在要处理的action类里加入
public InputStream getInputStream() throws FileNotFoundException {
		  return new FileInputStream(fileName);//绝对路径
	}



2 xml配置
 <result type="stream" name="download">
				<param name="contentType">application/octet-stream</param>
				<param name="inputName">inputStream</param>
				<param name="contentDisposition">attachment;filename="${fileName}"</param>
				<param name="bufferSize">4096</param>
            </result>
分享到:
评论

相关推荐

Global site tag (gtag.js) - Google Analytics