日期:2014-05-16 浏览次数:20668 次
onComplete: function (event, queueID, fileObj, response, data) {
alert(response);//此处得到结果为 {"message","上传OK"}
alert(response.message);// 此处是null....为什么
alert("文件:" + fileObj.name + "上传成功");
}
public class UpLoadAction extends ActionSupport{ private File file; private String fileFileName; private String message; public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String execute(){ System.out.println("文件名是"+fileFileName+file); String root=ServletActionContext.getServletContext().getRealPath("/upload"); try { byte[]b=new byte[1024]; int length; InputStream read=new FileInputStream(file); OutputStream write=new FileOutputStream(new File(root,fileFileName));//文件名保存为例 while((length=read.read(b))!=-1){ write.write(b, 0, length); } read.close(); write.close(); } catch (FileNotFoundException e) { // TODO Auto-generated catch block e.printStackTrace(); } catch (IOException e) { // TODO Auto-generated catch block e.printStackTrace(); } message="我是服务器"; return SUCCESS; } public void setFile(File file) { this.file = file; } public void setFileFileName(String fileFileName) { this.fileFileName = fileFileName; } }