spring 415

不支持的媒体类型

spring mvc 使用@requestBody注解json请求时,jQuery有限制,否则会出现 415 错误

1、使用ajax 
$.ajax({
                data: JSON.stringify(Abstract.searchCondition),
                url: url,
                async: true,
                type: 'post',
                contentType: 'application/json',
                success: function (response) {
                    
                },
                complete:function(){               
                },
                error: function (XMLHttpRequest, timeout, errorThrown) {
                }
            });  
2、使用post
$.ajaxSetup({
headers: {'Content-type': 'application/json;charset=UTF-8'}
});
     $.post('/applications/overview/getTransactionsChartData',
        JSON.stringify(data), function (response) {
}
}, 'JSON');
};




posted @ 2015-10-12 15:09  skyding  阅读(223)  评论(0编辑  收藏  举报