Custom error page - get originally requested URL

断了今生、忘了曾经 提交于 2019-11-29 14:31:14

The <error-page> is under the covers served by a RequestDispatcher#forward() call. All details of the original request are available as request attribues which are keyed by the keys as identified by RequestDispatcher#FORWARD_XXX constants:

You as starter should know that all request attributes are in EL available via the implicit EL object #{requestScope}.

So, all with all, this should do in the view:

<p>Unfortunately, the page you requested, #{requestScope['javax.servlet.forward.request_uri']} does not exist</p>

And equivalently, this should do in the bean, if necessary:

String forwardRequestURI = externalContext.getRequestMap().get(RequestDispatcher.FORWARD_REQUEST_URI);
samuelgrigolato

You might be able to get that URL with the "referer" (misspelled) request header.

http://www.w3.org/Protocols/rfc2616/rfc2616-sec14.html#sec14.36

Java usage: HttpServletRequest - how to obtain the referring URL?

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!