* 下载
* @author kowen
*
*/
public class DownloadAction extends BaseAction{
private String fileName;
private String downloadName;
public InputStream getDownloadFile() throws Exception
{
InputStream input = ServletActionContext.getServletContext().getResourceAsStream(fileName) ;
return input;
}
@Override
public String execute() throws Exception {
return SUCCESS;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
* 获取下载文件名
*/
public String getDownloadName() {
if(downloadName==null){
return fileName;
}
if(downloadName.contains(".")){
return downloadName;
}else{
String suffix = fileName.substring(fileName.lastIndexOf("."));
return downloadName+suffix;
}
}
public void setDownloadName(String downloadName) {
this.downloadName = downloadName;
}
}