idea中,前端访问localhost:8001/payment/create?serial=333,报下列错误 。
Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content type 'application/x-www-form-urlencoded;charset=UTF-8' not supported]
原因分析:postman中发送请求:localhost:8001/payment/create?serial=333,类型是x-www-form-urlencoded;charset=UTF-8 ,而我们在后端里使用了@RequestBody,只能接收前端传过来的json数据。
解决方案:
方案一:去掉@RequestBody注解,可以采用@RequestParam接收就行,前端和后台数据对应
方案二:在postman中就采用json格式
{
"serial":"12313",
"name":"韵升初"
}