struts2 头像上传
类似qq空间的头像上传,可以处理的。谢谢大家
------解决方案--------------------action层 private File file;
private String fileFileName;
private String fileContentType;
String url = "images\\ticket\\upload";
String path=ServletActionContext.getServletContext().getRealPath(url);
File f=new File(new File(path),time+"-"+fileFileName);
if(!f.getParentFile().exists()){
f.getParentFile().mkdirs();
}
FileUtils.copyFile(file,f);
ticket.setImage(url+"\\"+time+"-"+fileFileName);
}
ticketService.mergeTicket(ticket);
form 必须加和这个enctype="multipart/form-data"
------解决方案--------------------