2 回答

TA貢獻1893條經驗 獲得超10個贊
首先,Postman 默認會自動跟隨重定向。您在 Postman 中得到的是已經重定向到的響應/www.google.com
。轉到設置將其關閉:
二redirect:/www.google.com
是不同redirect://www.google.com
。假設您的服務器是127.0.0.1:8080
:
redirect:/www.google.com
--> 重定向到http://127.0.0.1:8080/www.google.com
redirect://www.google.com
--> 重定向到http://www.google.com
所以你實際上重定向回你的服務器,你收到的 401 錯誤可能是由于你的服務器的訪問控制。

TA貢獻1818條經驗 獲得超8個贊
就我而言,它工作正常,請檢查:
@ControllerAdvice
public class ErrorHandler {
@ExceptionHandler(CustomRuntimeException.class)
@ResponseStatus(value=HttpStatus.OK)
public ModelAndView handleCustomRuntimeException(HttpServletRequest request, HttpServletResponse response, Exception ex) {
ModelAndView mav = new ModelAndView("error");
mav.addObject("error", "500");
return mav;
//return new ModelAndView("redirect:https://www.google.com");
}
}
添加回答
舉報