求各位大侠指点
代码:
public class fileAction extends ActionSupport{
private static final long serialVersionUID = 1L;
private File file; // 实际上传文件
private String fileContentType; // 文件的内容类型
private String fileName; // 上传文件名
public File getFile() {
return file;
}
public void setFile(File file) {
this.file = file;
}
public String getFileContentType() {
return fileContentType;
}
public void setFileContentType(String fileContentType) {
this.fileContentType = fileContentType;
}
public String getFileName() {
return fileName;
}
public void setFileName(String fileName) {
this.fileName = fileName;
}
public static String getExt(String Name)
{
return Name.substring(Name.lastIndexOf("."));
}
public String execute() throws Exception{
HttpServletResponse response=ServletActionContext.getResponse();
response.setContentType("text/html;charset=utf-8");
response.setHeader("Cache-Control", "No-Cache");
if(file!=null)
{
String saveUrl=ServletActionContext.getServletContext().getRealPath("d:/test/upload"); //获取文件存储路径
File dirFile=new File(saveUrl);
if(!dirFile.exists()) //判断文件目录是否存在,不存在,则创建
{
dirFile.mkdir();
}
String realName = UUID.randomUUID().toString()+ getExt(fileName);
File target = new File(saveUrl, realName);
FileUtils.copyFile(file, target); // 上传至服务器的目录,
return SUCCESS;
}
else {
return INPUT;
}
}
报错如下:
2013-8-27 10:03:19 com.opensymphony.xwork2.validator.ActionValidatorManagerFactory <clinit>
信息: Detected AnnotationActionValidatorManager, initializing it...