Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

HttpMediaTypeNotAcceptableException

I am having problem with my jQuery function what I am trying to achieve is to populate data in a listbox

The JavaScript function

function load() {
        $.getJSON('${findAdminGroupsURL}', {
            ajax : 'true'
        }, function(data) {
            var html = '<option value="">Groups</option>';
            var len = data.length;
            for ( var i = 0; i < len; i++) {
                html += '<option value="' + data[i].name + '">' + data[i].name
                        + '</option>';
            }
            html += '</option>';

            $('#selection').html(html);
        });
    }

The server side is

@RequestMapping(value = "groups", method = RequestMethod.GET)
    public @ResponseBody
    List<Group> getGroups() {
        return this.businessGroups();
    }

I call load() function on load it triggers the function getGroups() and returns the list successfully but the problem is once the getGroups() is finished

function(data) doesn't load never gets into that function and the error is

org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation

Can't I post back a list of Group objects, or does it have to be a Java primitive type?

like image 961
Pinchy Avatar asked Jun 17 '11 13:06

Pinchy


1 Answers

A similar post I found today ..

Spring's Json not being resolved with appropriate response

Hope this might help

http://forum.springsource.org/showthread.php?85034-HttpMediaTypeNotAcceptableException-(always)

like image 170
Boopathi Rajaa Avatar answered Oct 03 '22 19:10

Boopathi Rajaa