如何使用Servlet从请求中获取上一页URL [英] How to get previous page URL from request using a servlet
本文介绍了如何使用Servlet从请求中获取上一页URL的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
如何使用servlet从请求中获取上一页URL.例如,我来自index.html,并且我提交了来自index的表单,如何获取index.html URL并在servlet中使用它?
How do I get the previous page URL from request using a servlet. For example, I'm from the index.html and I submitted a form from index, how do I get the index.html URL and use it in a servlet?
request.getRequestURL()
getRequestURL不起作用,因为它仅返回servlet的URL.
getRequestURL doesn't work since it only returns the URL of the servlet.
推荐答案
在Servlet中编写以下代码
Write in your Servlet the following code
字符串url = request.getHeader("referer");
String url = request.getHeader("referer");
这对我来说很有效.希望它也对您有用
This worked in my case.Hope it works for you as well
这篇关于如何使用Servlet从请求中获取上一页URL的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文