【问题标题】:org.springframework.web.HttpMediaTypeNotAcceptableException: Could not find acceptable representation" errororg.springframework.web.HttpMediaTypeNotAcceptableException:找不到可接受的表示”错误
【发布时间】:2012-06-22 12:49:16
【问题描述】:

我像这样调用 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;
    } 

【问题讨论】:

    标签: java jquery json jsp spring-mvc


    【解决方案1】:

    把下面的requestMapping:

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

    【讨论】:

      猜你喜欢
      • 2014-04-18
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-06-04
      • 2016-09-28
      相关资源
      最近更新 更多