在我当前的项目中,我有一个与主站点集成的购物车。现在我必须创建一些迷你站点来显示从主站点检索的数据。当用户单击迷你网站中的“立即购买”按钮时,它应该重定向到主购物车。但是,当用户单击“继续购物”按钮时,应该将其发送回他正在浏览的迷你网站页面。两个站点将使用 2 个不同的域名。我可以让他回到他浏览我们的页面吗?
request.getHeader("Referer")
这将是 2 个不同的 Web 应用程序,因此 request.getHeader("Referer")
将帮助他返回到他正在浏览的页面。
请给我一些建议。
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")
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.
Please send me some suggestions.
发布评论
评论(2)
您不应依赖
Referer
来实现应用程序的逻辑,因为发送Referer
可能会被防火墙或浏览器配置阻止。考虑将返回 URL 作为参数传递:
http://mainsite.com/shoppingCart?returnTo=http%3a%2f%2fminisite.com%2foriginalPage
。另请确保
returnTo
指向您的网站,以避免可能的安全问题。You shouldn't rely on
Referer
for the logic of your application, since sendingReferer
can be blocked by firewalls or browser configuration.Consider passing return URL as a parameter instead:
http://mainsite.com/shoppingCart?returnTo=http%3a%2f%2fminisite.com%2foriginalPage
.Also make sure that
returnTo
points to your site to avoid possible security problems.这似乎是正确的语法:
this seems to be the correct syntax: