postman发送json参数到后端controller报错415的解决方案

警告 [http-nio-8080-exec-9] org.springframework.web.servlet.handler.AbstractHandlerExceptionResolver.logException Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/json;charset=UTF-8' not supported]

大概出现了这样的问题,前端用ajax可以正常post,但是如果用postman,只能用表单数据发送,如果用json,后端controller收到的永远是null。
@RequestBody 和 @RequestParam都试过了。

原因应该是缺少json解析的依赖包,所以maven里加入jackson json的三个包即可。

猜你喜欢

转载自www.cnblogs.com/zxcoder/p/11837197.html