簡體   English   中英

錯誤 415 angular spring 引導應用程序的媒體類型不受支持

[英]error 415 Unsupported Media Type for an angular spring boot application

我開發了一個 angular 8 Spring boot 2 應用程序

我嘗試從 angular 服務發送 POST 請求,但出現錯誤 415 Unsupported Media Type

服務 angular

const headers = new HttpHeaders({ 'Content-Type': 'application/json' });
const options = { headers: headers };
return this.http.post<Search>('/api/produitimmobilier/all', search, options).pipe(.......

我嘗試了我的 spring 啟動 2 controller 的 2 個配置:

@RequestMapping(value = "/produitimmobilier/all",
method = RequestMethod.POST,consumes ="application/json")
@ResponseBody
public Search findAll(@RequestBody Search search){

@RequestMapping(value = "/produitimmobilier/all",
method = RequestMethod.POST,consumes = {"text/plain;charset=UTF-8", MediaType.APPLICATION_JSON_VALUE})
@ResponseBody
public Search findAll(@RequestBody Search search){

但我有同樣的錯誤。 你能幫助我嗎?

我發現了這個錯誤,搜索 object 中有一個錯誤的映射,這是一個不正確的設置器。 討論結束。 感謝您轉發此帖子

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM