0
我試圖捕獲一個錯誤場景,但在所有情況下我都得到一個異常。在成功的情況下調用控制器的Spring MVC @ExceptionHandler方法
下面是我的代碼片段:
@RequestMapping(value = "/config/file/data", method = RequestMethod.GET)
@ResponseBody
@ExceptionHandler(RestClientException.class)
@ResponseStatus(value = HttpStatus.NOT_FOUND, reason = "Not Found")
public void restClientException()
{
//do nothing
}
public List<myfile> getAllmyfiles() throws RestClientException
{
return myfileService.getAllmyfiles();
}
發佈一些測試或例外。 getAllmyfiles()在任何地方都被調用,並且沒有用@RequestMapping註釋,如果你想要一個答案,請添加更多的上下文 –
更新我的代碼..在成功的情況下獲取數組列表返回Arrays.asList(myfile);但在控制器不知道如何exceptionhandler調用 – JOGO