如何获取导致404错误的请求页面的URL?
例如,我输入http://example.com/path/does/not/exist/index.jsp 我已经有了一个自定义404页面,但我如何检索上面提到的URL以便我可以显示它的消息类似于"网址http://example.com/path/does/not/exist/index.jsp不存在"?
如果使用forward转到错误页面,则可以获取原始请求URL
request.getAttribute("javax.servlet.forward.request_uri")
Run Code Online (Sandbox Code Playgroud)
或EL
${requestScope['javax.servlet.forward.request_uri']}
Run Code Online (Sandbox Code Playgroud)