开发者

How to get the forward information in JSTL / EL, being an attribute containing a dot

开发者 https://www.devze.com 2023-01-31 13:01 出处:网络
This question shows that when forwarding, the information in the request object is updated to reflect the new file. So for example, when:

This question shows that when forwarding, the information in the request object is updated to reflect the new file. So for example, when:

user requests "/abc" -> servlet is invoked > forwards to /def.jsp

Then in def.jsp ${request.requestURI} will be /def.jsp rather than /abc. If one wants to obtain the original requested URI (or any other information, like servlet path, etc):

request.getAttribute("javax.servlet.forward.request_uri");

All fine, but how can I access this via JSTL. ${javax开发者_运维百科.servlet.forward.request_uri} doesn't work. The dot is considered an operator, rather than part of the name. In other cases, this is solved by putting the name in square brackets and quoting it. But here there is no map object, and ${['javax.servlet...']} does not work.

So, how?

(I can put it in a "dotless" attribute in the servlet, but that's a workaround)


As far as I remember, it's something like this:

${requestScope["javax.servlet.forward.request_uri"]}
0

精彩评论

暂无评论...
验证码 换一张
取 消