我试图在我的控制器中捕获错误情况,但我在所有情况下都会遇到异常。
以下是我的代码段:
@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();
}
答案 0 :(得分:0)
我认为你在这里有些困惑。 当服务器无法访问时,您的控制器将不可用,它将无法工作。
如果您想在服务器不可用时执行某些逻辑,则必须在前端(例如,JS)中执行此操作。您无法在Controller对象中执行此操作。