开发者

Can not deserialize instance of CUSTOM_CLASS out of START_ARRAY token

开发者 https://www.devze.com 2023-04-11 08:44 出处:网络
I am trying to send an objects array to Spring con开发者_开发知识库troller via jQuery AJAX. Here is the javascript code:

I am trying to send an objects array to Spring con开发者_开发知识库troller via jQuery AJAX. Here is the javascript code:

var data = new Array();
        $.each(products, function (i) {
            var temp = {};
            temp.orpid = products[i].orpid;
            temp.orpah = $('#orpah' + products[i].orpid).is(':checked');
            temp.orpad = $('#orpad' + products[i].orpid).val();
            data.push(temp);
        });
        $.postJSON(url + 'save',
                data,
                function(response) {
                    if (response.isAuthenticated && response.isAuthorized) {
                        if (response.hasErrors) {
                            $('#routeForm').setErrors(response.errors);
                            hideWait();
                        }
                    }
                    else
                        redirectToLogin();
                });

The params that are sended to server:

[{"orpid":10,"orpah":false,"orpad":""},{"orpid":11,"orpah":false,"orpad":""}]

The problem is that server response with 500 error:

Can not deserialize instance of XXX out of START_ARRAY token 

where xxx is the name of my custom form class.

Could somebody explain me where is the problem? Thank you


Here is my solution. Only thing you have to do is to create separate object at server side.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号