关于struts2 批量下载文件,代码写好了,但是出现异常,严重: Can not find a java.io.InputStream with the na
麻烦大家帮我看看,在网上搜索了一下,但是都没有结果!
action代码:
package cn.edu.cuit.disasterSystem.web.struts2.action;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import
java.io.IOException;
import java.io.InputStream;
import
java.io.UnsupportedEncodingException;
import java.text.SimpleDateFormat;
import java.util.Date;
import org.apache.struts2.ServletActionContext;
import org.apache.tools.zip.ZipEntry;
import org.apache.tools.zip.ZipOutputStream;
import com.opensymphony.xwork2.ActionSupport;
@SuppressWarnings("serial")
public class DownloadAction extends ActionSupport {
private String filenames;
private String filepaths;
private String[] filenameArray = null;
private String[] filepathArray = null;
private String filename;
private String filepath;
private SimpleDateFormat format = new SimpleDateFormat("yyyyMMddHHmmss");
public String getFilenames() {
return filenames;
}
public void setFilenames(String filenames) {
this.filenames = filenames;
if (this.filenames.contains("|")) {
parseFilenamesToArray();
}
}
public String getFilepaths() {
return filepaths;
}
public void setFilepaths(String filepaths) {
this.filepaths = filepaths;
if (this.filepaths.contains("|")) {
parseFilepathsToArray();
}
}
public void parseFilenamesToArray() {
filenameArray = filenames.split("\\|");
}
public void parseFilepathsToArray() {
filepathArray = filepaths.split("\\|");
}
public String getFilename() {
try {
return new String(filename.getBytes(), "ISO-8859-1");
} catch (Unsupported
EncodingException e) {
e.printStackTrace();
return filename;
}
}
public String getFilepath(){
return filepath;
}
public void initFilename() {
if(isBaleZip()){
this.filename = "批量打包下载.zip";
}else{
this.filename = getFilenames();
}
System.out.println("下载文件名: "+filename);
}
public void initFilepath() {
if(isBaleZip()){
String rootpath = ServletActionContext.getServletContext().getRealPath("/upload/temp");
String requestip = ServletActionContext.getRequest().getLocalAddr();
//this.filepath = "c:\\批量打包下载.zip";
this.filepath = rootpath+"\\"+requestip+"-"+format.format(new Date())+".zip";
}else{