ExtJs上传文件 兼容IE (Extjs4.2+Restful风格访问后台)

来源:互联网 发布:c语言中运算符的优先级 编辑:程序博客网 时间:2024/06/06 06:56

IE浏览器不支持返回的数据的头格式application/json,需要将返回数据的头格式改为text/html。


Controller:

form.submit({
                    url : 'ra/blMgr/insertbatch',
                    waitMsg : '正在导入  ...',
                    success : function(form, action) {
                    me.searchBtnClicked(btntemp);
                        var data = Ext.JSON.decode(action.response.responseText);
                        Ext.Msg.alert("导入成功", data.error);
                        window.close();
                        excelWindow.close();
                    },
                    failure : function(form, action) {
                        var data = Ext.JSON.decode(action.response.responseText);
                        Ext.Msg.alert("导入失败", data.error);
                        window.close();
                        excelWindow.close();
                    }
                });


Service:

    @Path("/insertbatch")
    @Consumes(MediaType.MULTIPART_FORM_DATA)
    @Produces(MediaType.TEXT_HTML)
    @POST
    public String insertbatch(MultipartFormDataInput formDataInput) {
     
.......

if(resp.isSuccess()){
return "{'success':true}";
}else{
return "{'success':false,'error':'"+resp.getErrorMsg()+"'}";

    }

0 0
原创粉丝点击