Struts2: Get the URL from which the user came

How can I get the URL from which the user came to my Struts2 action?

+3
source share
2 answers

Try:

request.getHeader("referer");  

You can also create a hidden field in the form, and then use the if statement to check and route accordingly.

I would recommend you use a hidden field. Although this is certainly more of a hassle, it is also more reliable. The abstract field can be removed from the HTTP header by the proxy server. In fact, the browser does not need to send the referer field to the header at all.

See a good discussion here . The above explanation is an excerpt from this discussion.

+2

HTTP-:

String url = request.getHeader("referer");

, , . , .

- .

+1

Source: https://habr.com/ru/post/1763603/


All Articles