我使用的彈簧DefaultPropertiesPersister加載託管輸入流中另一臺服務器上我的屬性,如下圖所示:DefaultPropertiesPersister加載和處理HTTP錯誤
Resource resource = this.resourceLoader.getResource(url);
InputStream is = resource.getInputStream();
propertiesPersister.load(props, new InputStreamReader(is, encoding));
如果URL返回類似404頁的HTTP錯誤未找到或500內部服務器錯誤,我該如何處理。
我在問,因爲在出現404和500錯誤的情況下,服務器將返回一個錯誤頁面,該頁面可以轉換爲InputStream,這使得它成爲PropertiesPersister的有效輸入。
我想抓住和處理HTTP錯誤,請幫助。