import="com.ibatis.struts.ActionContext,java.io.*" pageEncoding="utf-8"%>
ActionContext ctx = ActionContext.getActionContext();
int byteRead = 0;
try {
String path = ctx.getRequest().getRealPath("");
String fileNameInfo = ctx.getRequest().getParameter("fileName");
byte[] a = fileNameInfo.getBytes("iso-8859-1");
String temp = java.net.URLEncoder.encode(new String(a, "utf-8"), "UTF-8");
temp = StringUtils.replace(temp, "+", "%20");
String attachFileName = java.net.URLEncoder.encode(temp, "utf-8");
ctx.getResponse().setHeader(
"Content-disposition",
"attachment; filename="
+ java.net.URLDecoder.decode(attachFileName,
"UTF-8"));
ctx.getResponse().setContentType("utf-8");
ctx.getResponse().setCharacterEncoding("utf-8");
System.out.println(path + "//common//upload//"
+ new String(a, "UTF-8"));
FileInputStream fis = new FileInputStream(path
+ "//common//upload//" + new String(a, "UTF-8"));
OutputStream os = ctx.getResponse().getOutputStream();
while (-1 != (byteRead = fis.read())) {
os.write(byteRead);
}
os.close();
out.clear();
out = pageContext.pushBody();
if (fis != null) {
fis.close();
}
} catch (FileNotFoundException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
%>