0

我称 JSON 为:

$(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);
                        });
                    });
                });  

它击中控制器并根据 id 获取适当的对象。

但它给出了“ org.springframework.web.HttpMediaTypeNotAcceptableException:找不到可接受的表示”错误。

我的控制器类:

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

1 回答 1

1

把下面的requestMapping:

@RequestMapping(method = RequestMethod.GET, value = "/jassg.html", produces = "application/json")
于 2012-09-23T21:41:06.333 回答