StringHttpMessageConverter乱码问题的解决(Spring 3.2)
特别标注了是Spring 3.2,在网上搜了半天,很多配置应该是老版本的缘故,导致我配置了StringHttpMessageConverter转换编码始终不起作用(也有可能是我个人的错误)。后来在Stackoverflow找到了应该算是正确的配置方式,至少我的是可以运行了:
在Spring MVC的配置文件中配置以下:
<mvc:annotation-driven><mvc:message-converters><bean name="code"> onComplete : function(request) { var me = this, options = request.options, result, success, response; try { result = me.parseStatus(request.xhr.status); } catch (e) { // in some browsers we can't access the status if the readyState is not 4, so the request has failed result = { success : false, isException : false }; } success = result.success; if (success) { response = me.createResponse(request); me.fireEvent('requestcomplete', me, response, options); Ext.callback(options.success, options.scope, [response, options]); } else { if (result.isException || request.aborted || request.timedout) { response = me.createException(request); } else { response = me.createResponse(request); } me.fireEvent('requestexception', me, response, options); if(!options.failure){ options.failure = function(result,request){ Ext.MessageBox.show({ title : "出错了", multiline: true, value : response.responseText, msg : "操作失败,失败原因:",width : 300, icon : Ext.MessageBox.ERROR, buttons : Ext.MessageBox.YES }); } } Ext.callback(options.failure, options.scope, [response, options]); } Ext.callback(options.callback, options.scope, [options, success, response]); delete me.requests[request.id]; return response; },
if(!options.failure){ options.failure = function(result,request){ Ext.MessageBox.show({ title : "出错了", multiline: true, value : response.responseText, msg : "操作失败,失败原因:",width : 300, icon : Ext.MessageBox.ERROR, buttons : Ext.MessageBox.YES }); } }