日期:2014-05-17 浏览次数:20722 次
<action name="muxz_action2" class="updownfiles.DownFilesAction" >
<result name="success" type="stream">
<!-- 下载文件类型定义 -->
<param name="contentType">${mimeType}</param>
<!-- 下载文件处理方法 -->
<param name="contentDisposition">
attachment;filename="${downFileName}"
</param>
<!-- 下载文件输出流定义 getFileInputStream() -->
<param name="inputName">fileInputStream</param>
<param name="bufferSize">4096</param>
</result>
</action>
public InputStream getFileInputStream() throws Exception {
return fileInputStream;
}
public String getMimeType() {
return ServletActionContext.getServletContext().getMimeType(downFileName);
}
public String getDownFileName() {
String FileName = downFileName;
try {
//对文件名转码, 不然在下载的时候文件名是乱码.
if(ServletActionContext.getRequest().getHeader("USER-AGENT").toLowerCase().indexOf("msie") > 0 ? true : false){
FileName = new String(FileName.getBytes("GBK"), "ISO-8859-1");
}else{
FileName = new String(FileName.getBytes("UTF-8"), "ISO-8859-1");
}
} catch (UnsupportedEncodingException e) {
&n