//工具类如下:
public static Map<String,
Object> writeData(LicenseDTO dto) throws
Exception{
Map<String, Object> map = new
HashMap<String, Object>();
String fileName = dto.getOrgName();
//先创建一个txt文件
File file = new File(fileName+"License.txt");
}
Action类:
private InputStream inputStream;
private String fileName;
public String output(){
try {
Map<String, Object> map =
licenseService.output(ids);
fileName = (String) map.get("fileName");
fileName = new String(fileName.getBytes(),"ISO_8859_1");
//处理中文乱码
inputStream = (InputStream) map.get("Stream");
} catch (Exception e) {
e.printStackTrace();
}
return "exportSUCCESS";
}
在struts.xml里配置:
<result type="stream"
name="exportSUCCESS">
<param
name="ContentType">application/zip</param>
<!-- 配置内容类型
-->
<param
name="inputName">inputStream</param>
<!-- 要返回的数据 -->
<param
name="ContentDisposition">filename=${fileName}</param>
</result>
前台就直接一个连接OK:
window.location.href=_url;
_url自己定义啊