一:前台页面
二:Action
public class UploadAction extends BaseAction {
private String title;
// myFile属性用来封装上传的文件
private File myFile;
// myFileContentType属性用来封装上传文件的类型
private String myFileContentType;
// myFileFileName属性用来封装上传文件的文件名
private String myFileFileName;
public String createNewsMedia() {
map = new HashMap
();
map.put("success", 1);
String realpath = GetProperties.getValue("messagePath");
File savefile = new File(new File(realpath), myFileFileName);
if (!savefile.getParentFile().exists())
savefile.getParentFile().mkdirs();
try {
FileUtils.copyFile(myFile, savefile);
} catch (IOException e) {
e.printStackTrace();
}
return "toList";
}
//省略set和get方法
}