提问人:Andika Eka 提问时间:11/12/2023 更新时间:11/12/2023 访问量:15
Spring PostMapping consumes 参数不起作用
Spring PostMapping consumes argument does not work
问:
我正在尝试创建一个端点,该端点接受带有application/x-www-form-urlencoded请求正文的发布请求。
@PostMapping(
path = "/Products",
consumes = {
MediaType.APPLICATION_FORM_URLENCODED_VALUE,
MediaType.APPLICATION_JSON_VALUE,
MediaType.MULTIPART_FORM_DATA_VALUE
})
但是,它仍然返回 415 状态代码。 以下是日志:
2023-11-12T20:10:23.522+08:00 WARN 172604 --- [nio-8181-exec-2] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'multipart/form-data;boundary=--------------------------705954226533031493911721;charset=UTF-8' is not supported]
2023-11-12T20:10:35.460+08:00 WARN 172604 --- [nio-8181-exec-4] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'multipart/form-data;boundary=--------------------------977139678178024076998602;charset=UTF-8' is not supported]
2023-11-12T20:10:40.831+08:00 WARN 172604 --- [nio-8181-exec-5] .w.s.m.s.DefaultHandlerExceptionResolver : Resolved [org.springframework.web.HttpMediaTypeNotSupportedException: Content-Type 'application/x-www-form-urlencoded;charset=UTF-8' is not supported]
我做错了什么?
答: 暂无答案
评论