我正在调用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;
}
答案 0 :(得分:1)
请输入以下requestMapping:
@RequestMapping(method = RequestMethod.GET, value = "/jassg.html", produces = "application/json")