Ext做文件上传的时候发现,如果上传成功后从后台取返回信息,出现错误。
var importForm = new Ext.FormPanel({
labelAlign:'right',
buttonAlign:'right',
frame:true,
title: '',
bodyStyle:'padding:5px 5px',
width:450,
url:'importAction.do?method=importAlarmRule',
fileUpload: true,
items: [{
xtype: 'textfield',
fieldLabel: '<bean:message key="aloes.message.resource.import.file" />',
name: 'importFile',
width: 270,
height:20,
allowBlank:false,
blankText: '<bean:message key="aloes.message.resource.import.file.select" />',
inputType: 'file'//文件类型
}],
buttons: [{
text: '<bean:message key="button.save" />',
handler: function() {
importForm.getForm().submit({
success: function(fileform, action){
if(action.result.success == 'true'){
Ext.Msg.alert('<bean:message key="info.header" />', '<bean:message key="aloes.message.resource.import.success" />',function(){
importWin.close();
});
}else if(action.result.failure == 'formatError'){
Ext.Msg.alert('Error', '<bean:message key="aloes.message.resource.import.failed" />'+action.result.info);
}
},
failure: function(){
Ext.Msg.alert('<bean:message key="message.error" />', '<bean:message key="aloes.message.resource.import.failed" />');
}
});
}
},{
text: '<bean:message key="button.cancel" />',
handler: function() {
importWin.close();
}
}]
});
var importWin = new Ext.Window({
id:'import-window',
title: '<bean:message key="aloes.message.resource.import" />',
closable:true,
width:460,
maximizable:false,
modal:true,
plain:true,
items:[importForm]
});
importWin.show();
后台的java代码往前台送数据的时候:
resultStr.append("{'failure':'false','success':'true'}");
response.setContentType(" text/html;charset=utf-8 ");
response.getWriter().print(resultStr);
contentType必须为:" text/html;charset=utf-8 "
而不能为:" text/xml;charset=utf-8 "
否则前台会报错。
分享到:
相关推荐
赠送jar包:commons-fileupload-1.4.jar; 赠送原API文档:commons-fileupload-1.4-javadoc.jar; 赠送源代码:commons-fileupload-1.4-sources.jar; 赠送Maven依赖信息文件:commons-fileupload-1.4.pom; 包含...
Ext3_FileUploadExt上传文件
文件上传 FileUpload 控件,分享
整个代码 博文链接:https://canofy.iteye.com/blog/143075
Apache Commons FileUpload 1.3.3,开源的文件上传jar包
内含文档说明和demo演示!~ 用struts的commons-fileUpload.jar实现文件上传,所以文件都可以,并另加图片预览功能!~ 采用简单常用jsp+servlet实现,同样对使用struts实现上传进行了说明~
commons-fileupload-1.2.2.jar是一款可以实现文件上传功能的jar依赖包,一般进行应用开发的朋友会用到这个开发包,下载后放到应用程序的WEB-INF\lib下就可以正常使用了,有从事web开发的朋友不要错过。
net使用FileUpLoad控件上传文件 单个文件的上传:保存到上传服务器指定目录得到上传文件的文件名(含上传本地路径) 存储文件的详细信息,包括文件名,文件格式,文件大小和存储路径
commons-fileupload-1.3.1.jar
赠送jar包:commons-fileupload-1.3.3.jar; 赠送原API文档:commons-fileupload-1.3.3-javadoc.jar; 赠送源代码:commons-fileupload-1.3.3-sources.jar; 赠送Maven依赖信息文件:commons-fileupload-1.3.3.pom;...
使用commons-fileupload上传文件 使用commons-fileupload上传文件
Apache组织提供的一个开源组件Commons-FileUpload,该组件可以方便的将“multipart/form-data”类型请求中的各种表单域解析出来,并实现一个或多个文件的上传,同时也可以限制上传文件的大小等内容。其性能十分优异,...
C# .NET FileUpload 多文件上传例子,两个方法和思路,适合初学者学习。
java实现的文件上传下载FileUpLoad,内含SQL文件,使用Oracle数据库,struts2组件包装,包装流加快下载,可上传可下载,适合初学者学习使用!
primefaces中用<p:fileUpload组件来上传文件
commons-fileupload实现文件上传
赠送jar包:commons-fileupload-1.3.3.jar; 赠送原API文档:commons-fileupload-1.3.3-javadoc.jar; 赠送源代码:commons-fileupload-1.3.3-sources.jar; 赠送Maven依赖信息文件:commons-fileupload-1.3.3.pom;...
采用了Ajax技术 功能: 文件上传 特点: 动态显示进度, 百分比, (中文)文件名, 文件长度, 上传速度......说明:累计上传文件不超过10M(可以更改代码调整),当超过1M时可以看到进度条。请下载这个较新版本。
主要为大家详细介绍了使用fileupload实现文件上传功能,文中示例代码介绍的非常详细,具有一定的参考价值,感兴趣的小伙伴们可以参考一下
fileupload文件上传下载代码示例 fileupload文件上传下载代码示例