默认情况下,Spring Boot 将 /error
映射到 BasicErrorController
。我想记录异常以及导致异常的请求。如何在 BasicErrorController
或新的 CustomErrorController
中获取原始请求。当抛出异常并且原始请求信息消失或无法将错误与原始请求映射时,Spring Boot 似乎会向 /error
发出新请求。
最佳答案
获取方式:
String url = (String) request.getAttribute(RequestDispatcher.ERROR_REQUEST_URI);
关于java - Spring Boot 错误 Controller 检索原始请求,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54796889/