action类中代码
public class UploadPicAction extends ActionSupport {
private String picName;
private File pic;
private String picFileName;
private String picContentType;
public String getPicName() {
return picName;
}
public void setPicName(String picName) {
this.picName = picName;
}
public File getPic() {
return pic;
}
public void setPic(File pic) {
this.pic = pic;
}
public String getPicFileName() {
return picFileName;
}
public void setPicFileName(String picFileName) {
this.picFileName = picFileName;
}
public String getPicContentType() {
return picContentType;
}
public void setPicContentType(String picContentType) {
this.picContentType = picContentType;
}
@Override
public String execute() throws Exception{
String uploadPath = ServletActionContext.getServletContext().getRealPath("/upload");
String newFileName = UUID.randomUUID().toString() + picFileName.substring(picFileName.lastIndexOf("."));
//System.out.println(uploadPath + "/" + newFileName);
FileInputStream is = new FileInputStream(pic);
FileOutputStream os = new FileOutputStream(uploadPath + "/" +newFileName);
return SUCCESS;
}
}
pic的类型为File,但是报的错在FileInputStream上,说需将pic类型改为String,我用的new FileInputStream(File),请问是怎么回事