我正在嘗試構建一個彈簧控制器,它基本上充當地理服務器實體的反向代理。例如,如果客戶端想要訪問geoserver/wms?PARAM1=foo&PARAM2=bar,控制器將簡單地將請求轉發到實際的地理服務器實體并回傳回應。在我的例子中,geoserver 要么回傳一個 XML 有效載荷,要么回傳一個影像。
當使用回傳影像的 URL 測驗此控制器時,我能夠處理初始客戶端請求,將其轉發到地理服務器,然后處理它,但在向客戶端提供回應時出現以下錯誤:
There was an unexpected error (type=Internal Server Error, status=500).
No converter for [class [B] with preset Content-Type 'image/png'
org.springframework.http.converter.HttpMessageNotWritableException: No converter for [class [B] with preset Content-Type 'image/png'
![嘗試提供影像時,如何解決 Spring 中“使用預設 Content-Type 'image/png' 的 [class [B] 沒有轉換器”錯誤?](https://img.uj5u.com/2022/09/07/b6fe6687346e470391c3c2fe547cbc90.png)
發生 SpringDataRest 正在嘗試將適當的物件映射到content-type它找不到的物件。因此拋出一個通用的 500 例外。
轉載請註明出處,本文鏈接:https://www.uj5u.com/qita/505300.html
上一篇:驗證在String中收到的日期
