How to found out url with which the request arrived at error handler?

前端 未结 1 533
北荒
北荒 2021-01-15 00:58

I send following http request:

http://localhost:8081/member/createCompany/getSmallThumbnail/

On server side I hit into controller method:

相关标签:
1条回答
  • 2021-01-15 01:25

    Your request got redispatched to /error (presumably for error processing).

    If this framework follows the normal Servlet error dispatching behavior, then your original request can be found in the HttpServletRequest.getAttributes() under the various javax.servlet.RequestDispatcher.ERROR_* keys.

    • ERROR_EXCEPTION - The exception object
    • ERROR_EXCEPTION_TYPE - The type of exception object
    • ERROR_MESSAGE - the exception message
    • ERROR_REQUEST_URI - the original request uri that caused the error dispatch
    • ERROR_SERVLET_NAME - the name of the servlet that caused the error
    • ERROR_STATUS_CODE - the response status code determined for this error dispatch

    What you want is

    String originalUri = (String) request.getAttribute(
                                           RequestDispatcher.ERROR_REQUEST_URI)
    
    0 讨论(0)
提交回复
热议问题