前端用的Angluarjs框架
Game 实体类 属性有 id userid
    
$http({
        method: 'POST',
        data: {
            id: 1,
            userid: 2,
        },
        url: '../game/ra'
    }).then(function successCallBack(response) {
     
    }, function errorCallBack(response) {
    })java
 @RequestMapping(value = "/ra", method = RequestMethod.POST)
    @ResponseBody
    public int ra(@RequestBody Game game, HttpServletRequest request) {
        System.out.println(game.getId()+game.getUserid());
        System.out.println(request.getParameter("id") );        return 4;    }
这么写就是正确的,game.getId() game.getUserid()就能收到数据,但是request.getParameter("id") 就是null
                $.post("../game/r", {
                       id:1,
                       userid:2
                    },
                    function () {})
                    .success(function (data, status) {
                    }).error(function (data, status) {
                }
这么写java部分就必须去掉@RequestBody Game game,但是request.getParameter("id")却能收到值。
不然会报错Resolved exception caused by Handler execution: org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported看了下突然感觉像$.ajax的  contentType:"application/json",   试了下
$.ajax({ 
            type:"POST", 
            url:"../game/r", 
            dataType:"json",      
            contentType:"application/json",               
            data:JSON.stringify({"id":"1"},{"userid":"2"}), 
            success:function(data){ 
                                       
            } 
         }); 
但是只能收到game.getId()的数据,userid是null,request.getParameter("id")也是null
有大佬能解释下或者推荐个文章么,我刚学没多久,找了好多也没找到答案