【发布时间】:2019-11-13 02:31:05
【问题描述】:
@RestController
@RequestMapping("/user")
public class UserController {
@PostMapping(value = "/",
consumes = MediaType.APPLICATION_JSON_UTF8_VALUE,
produces = {MediaType.APPLICATION_JSON_VALUE})
public ResponseEntity<InternalUser> saveInternalUser(@RequestBody InternalUserDTO dto){
InternalUser user = internalUserService.saveInternalUser(dto);
return new ResponseEntity<>(user, HttpStatus.CREATED);
}
这是我的课。当我使用带有有效 json 的邮递员到该网址时 http://localhost:8090/user
我得到错误
Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded' not supported]
我试过这个 https://stackoverflow.com/a/38252762/11369236
我不想在这里使用 requestparam
https://stackoverflow.com/a/43065261/11369236
一些答案建议使用
consumes = MediaType.APPLICATION_JSON,
但是spring给出了错误:
attribute must be constant
我能做什么?
【问题讨论】: