ssh框架 使用struts上傳圖片
阿新 • • 發佈:2019-01-31
@SuppressWarnings("serial")
public class Add_action extends ActionSupport {
private ImgServlet imgServlet;
//圖片詳細
private String detailed;
// 封裝上傳檔案域的屬性
private File file;
// 封裝上傳檔案型別的屬性
private String fileFileName;
// 封裝上傳檔名的屬性
private String fileContentType;
public ImgServlet getImgServlet() {
return imgServlet;
}
public void setImgServlet(ImgServlet imgServlet) {
this.imgServlet = imgServlet;
}
public String getDetailed () {
return Detailed;
}
public void setName(String Detailed) {
this.name = Detailed;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = System.currentTimeMillis()+fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
@SuppressWarnings("unchecked")
public String execute(){
File destFile = null;
//獲得圖片儲存的路徑
String root = ServletActionContext.getServletContext().getRealPath("/upload");
try {
public class Add_action extends ActionSupport {
private ImgServlet imgServlet;
//圖片詳細
private String detailed;
// 封裝上傳檔案域的屬性
private File file;
// 封裝上傳檔案型別的屬性
private String fileFileName;
// 封裝上傳檔名的屬性
private String fileContentType;
public ImgServlet getImgServlet() {
return imgServlet;
}
public void setImgServlet(ImgServlet imgServlet) {
this.imgServlet = imgServlet;
}
public String getDetailed
return Detailed;
}
public void setName(String Detailed) {
this.name = Detailed;
}
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileFileName() {
return fileFileName;
}
public void setFileFileName(String fileFileName) {
this.fileFileName = System.currentTimeMillis()+fileFileName;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
@SuppressWarnings("unchecked")
public String execute(){
File destFile = null;
//獲得圖片儲存的路徑
String root = ServletActionContext.getServletContext().getRealPath("/upload");
try {