如何使用request.getHeader("Referer") [英] How to use request.getHeader("Referer")

查看:669
本文介绍了如何使用request.getHeader("Referer")的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在我当前的项目中,我有一个与主要站点集成的购物车.现在,我必须创建一些微型站点来显示从主站点检索到的数据.当用户单击迷你网站中的立即购买"按钮时,它应重定向到主购物车.但是,当用户单击继续购物"按钮时,该按钮应发送回他正在浏览的迷你站点页面.这两个站点将使用2个不同的域名.我可以把他发回到他浏览我们的页面吗?

In my current project, I have a shopping cart integrated with the main site. Now I have to create some mini sites to display the data retrieved from main site. When the user click buy now button in mini site, it should redirect to the main shopping cart. But when user click the Continue shopping button, that should be send back to the mini site page where he was browsing. Both sites will be in 2 different domain names. Can I send him back to the page where he was browsing us?

request.getHeader("Referer")

这将是2个不同的Web应用程序,因此request.getHeader("Referer")将有助于将他发送回他正在浏览的页面.

This will be 2 different web apps so will the request.getHeader("Referer") help to send him back to the page where he was browsing.

请给我一些建议.

推荐答案

您不应该依赖Referer来实现应用程序的逻辑,因为发送Referer可能会被防火墙或浏览器配置阻止.

You shouldn't rely on Referer for the logic of your application, since sending Referer can be blocked by firewalls or browser configuration.

考虑将返回URL作为参数传递:http://mainsite.com/shoppingCart?returnTo=http%3a%2f%2fminisite.com%2foriginalPage.

Consider passing return URL as a parameter instead: http://mainsite.com/shoppingCart?returnTo=http%3a%2f%2fminisite.com%2foriginalPage.

还要确保returnTo指向您的站点,以避免可能的安全问题.

Also make sure that returnTo points to your site to avoid possible security problems.

这篇关于如何使用request.getHeader("Referer")的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆