Spring REST, JSON “Can not handle managed/back reference 'defaultReference'” 415 Unsupported Media Type

前端 未结 7 1570
一整个雨季
一整个雨季 2020-12-28 17:16

I am trying to POST to http://localhost:9095/translators from an AngularJS front-end using Spring boot/Spring RestController backend.

I can do a GET and the response

7条回答
  •  没有蜡笔的小新
    2020-12-28 18:03

    You need @ResponseBody annotation like as follows:

    @RequestMapping(method = RequestMethod.POST, consumes = MediaType.APPLICATION_JSON_VALUE, produces = MediaType.APPLICATION_JSON_VALUE)
        @ResponseBody public User addTranslator(@RequestBody User user) {
            //translation.setTranslationId(null);
            return repository.saveAndFlush(user);
        }
    

提交回复
热议问题