我碰到過幾個Spring控制器的函數,它們拋出IOException異常。Spring控制器函數拋出異常的目的
@RequestMapping(method = ***)
@ResponseBody
public List<Offering> getOfferingDetailsList(HttpServletResponse response, @PathVariable("productIds") String productIdString, HttpServletRequest request) throws IOException
我懷疑這種異常拋出的使用,當上面沒有人捕獲和處理它時。
設置響應狀態如「response.setStatus(HttpStatus.SC_NOT_FOUND)」代替拋出這樣的異常是否正確?
在控制器中處理異常的標準方式是什麼?
這對我來說是新事物:)。會想嘗試一下。 thx pappu – user811602