No reference request is transmitted using ajax foreground, background using springmvc received, appeared in the case of 406
The back-end code is as follows:
@RequestMapping("findAll")
@ResponseBody
public Object findAll(HttpServletRequest request){
Map<String,Object> map = new HashMap<>();
map.put("name1","333");
return map;
}
ajax code is as follows:
$.ajax({
type:"post",
dataType:"json",
url:"${pageContext.request.contextPath}/studentController/findAll",
success:function(data){
alert("name的值为"+data.name1)
}
})
Analysis: When adding @ResponseBody, the request will eventually turn into a strong target return json format, there is no reason for the majority of 406 pilot jackson bag, my side is not the cause of the error plus mvc profile <mvc: annotation-driven />
Reference article: https://blog.csdn.net/weixin_40887477/article/details/81118295