Spring Rest Service抛出HTTP状态415

时间:2017-03-29 15:37:20

标签: java angularjs spring spring-mvc

您好我正试图从角度调用Spring休息服务,但我收到以下错误。即使是The Postman我也得到了同样的错误。看起来其他服务出了问题,它不接受json请求数据 HTTP状态415:服务器拒绝了此请求,因为请求实体的格式不受所请求方法所请求资源的支持。提前感谢所有人。

以下是代码

**Angular Code**
var req = {
                     method: 'POST',
                     url: 'http://localhost:9050/FastTrackALM/retrieveData/getEpicData',
                     headers: {
                       'Content-Type': 'application/json'
                     },
                     data: {'epicId': '1' }
                    }

                    $http(req).then(function(response){
                        console.log(response);
                    }, function(response){
                        console.log(response);
                    });


**REST SERVICE**
@RequestMapping(method=RequestMethod.POST, 
                    value="/getEpicData",
                    consumes={"application/json"},
                    produces={"application/json"})
    @ResponseBody
    @ResponseStatus(code = HttpStatus.OK)
    public DataActionObject insertStudentDetails(@RequestBody epicForm1 student){
        DataActionObject dataActionObject = new DataActionObject();
        dataActionObject=epicBusinessBean.getEpicData(student.getEpicId(), dataActionObject);
        return dataActionObject;
    }

DataActionObject是我的自定义类,它保存要返回给客户端的json日期以及消息和代码

0 个答案:

没有答案