【发布时间】:2019-01-29 09:53:46
【问题描述】:
我有这样的异常处理程序:
@ControllerAdvice
public classMyExceptionHandler extends ResponseEntityExceptionHandler {
@ExceptionHandler(MyRuntimeException.class)
public String handleMyRuntimeException(MyRuntimeExceptionexception ex){
LOGGER.info(ex.getMessage());
return "redirect:/www.google.com";
}
}
我执行 http 请求,我看到 Controller 处理了我的请求,然后 MyRuntimeException 正在抛出,handleMyRuntimeException 方法正在调用。但在邮递员中,我看到服务器返回 401 http 状态,并且在响应标头中看不到 www.google.com。
我做错了什么?
【问题讨论】:
-
你能试试
return new ModelAndView("redirect:/www.google.com");吗?
标签: java spring spring-mvc redirect exception-handling