How to know when the request is forwarded in a RequestWrapper object

不羁岁月 提交于 2019-11-29 15:40:29

The original request URI is available as request attribute with the key RequestDispatcher.FORWARD_REQUEST_URI.

String originalRequestURI = request.getAttribute(RequestDispatcher.FORWARD_REQUEST_URI);

if (originalRequestURI != null) {
    // It was forwarded. Now get the query string as follows.
    String originalQueryString = request.getAttribute(RequestDispatcher.FORWARD_QUERY_STRING);
}

Note: in older Servlet API versions you need to hardcode the key instead.

String originalRequestURI = request.getAttribute("javax.servlet.forward.request_uri");
// ...
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!