acrion
public class DownloadAction extends ActionSupport {
private String fileName;
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public InputStream getInputStream() throws FileNotFoundException{
System.out.println(fileName);
return new FileInputStream("D:\\qq\\"+fileName);
}
public String download(){
return Action.SUCCESS;
}
}
struts.xml
<action name="download" class="jsh.sturts.action.DownloadAction"
method="download">
<result name="success" type="stream">
<param name="contentType">text/plain</param>
<param name="inputName">inputStream</param>
<param name="contentDisposition">attachment;filename="${fileName}"</param>
<param name="bufferSize">1024</param>
</result>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Insert title here</title>
</head>
<body>
<a href="download?fileName=1232323.doc">doc</a>
</body>
</html>
问题出在哪里了
1 回答
落子鸢
TA贡献2条经验 获得超2个赞
问题已经解决 在getFileName中把return this.fileName;替换为 return new String(fileName.getBytes(), "ISO8859-1");
添加回答
举报
0/150
提交
取消