How to use request.getHeader(“Referer”)

北慕城南 提交于 2019-12-10 13:12:57

问题


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.


回答1:


You shouldn't rely on Referer for the logic of your application, since sending Referer 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.




回答2:


this seems to be the correct syntax:

getHttpServletRequest().getHeader("Referer"))


来源:https://stackoverflow.com/questions/5536577/how-to-use-request-getheaderreferer

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!