获取导致404的请求页面的URL [英] Get URL of page requested that caused a 404
本文介绍了获取导致404的请求页面的URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何获取导致404错误的请求页面的URL?
How would I get the URL of the page that was requested that caused the 404 error?
例如,我输入 http://example.com/路径/确实/不/存在/index.jsp 我已经有一个自定义的404页面,但是如何检索上面提到的URL,以便可以显示类似"URL
For example, I type I go to http://example.com/path/does/not/exist/index.jsp I already have a custom 404 page but how would I go about retrieving the URL mentioned above so that I can display it with a message similar to "The url http://example.com/path/does/not/exist/index.jsp does not exist"?
推荐答案
如果使用Forward进入错误页面,则可以通过
If forward was used to go to the error page, you can obtain the original request URL by
request.getAttribute("javax.servlet.forward.request_uri")
或通过EL
${requestScope['javax.servlet.forward.request_uri']}
这篇关于获取导致404的请求页面的URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文