JOHND
JOHND

Reputation: 2777

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

I am calling JSON like :

$(function() {
                    $("select#accountsubgroupid").change(function() {
                        alert('admin URL ----'+adminUrl);
                        $.getJSON("<%=request.getContextPath()%>/admin/jassg.htm?search=",{accountSubGroupId: $(this).val(), ajax: 'true'}, function(accountSubGroup){                          
                           alert('success---'+accountSubGroup.code);
                        });
                    });
                });  

It's hitting controller and also getting proper object based on the id .

But it's giving "org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation" error.

My controller class:

@ResponseBody
    @RequestMapping(value = "/jassg.htm")
    public AccountSubGroup getJsonObject(@RequestParam Long accountSubGroupId, HttpSession session) throws Exception
    {
        //***My code for getting object ***
        return accountSubGroup;
    } 

Upvotes: 0

Views: 8971

Answers (1)

Techky
Techky

Reputation: 431

Put the following requestMapping:

@RequestMapping(method = RequestMethod.GET, value = "/jassg.html", produces = "application/json")

Upvotes: 1

Related Questions