public Download extends ActionSupport{
private String fileName="";
public String getFileName() throws UnSupportedEncodingException{
return new String(fileName.getBytes("gbk"),"ISO-8859-1");
}
public void setFileName(String fileName) throw UnSupportedEncodingException{
this.fileName=new String(fileName.getBytes("ISO-8859-1");
}
public InputStream getDownloadFile() throws IOException{
ServletActionContext.getResponse().setContentType("application/x-msdownload");
FileInputStream in = new FileInputStream(ServletActionContext.getServletContext().getRealPath("")+"\\"+fileName);
return in;
}
public String execute() throw IOExcetpion{
return "success";
}
}
<action name="dowload" class="controller.Download">
<result name="success" type="stream">
<param name="inputName">downloadFile</param>
<param name="bufferSize">1024k</param>
</result>
</action>