简体   繁体   English

购买后将用户重定向到主页

[英]Redirect user to HomePage after buying

I am working with Reactjs in the UI and Java with Spring Boot in the Back End,我在 UI 中使用 Reactjs 和 Java 在后端使用 Spring 启动,

My question is, How can I redirect the user after buying a chocolate just for given an example to the HomePage if the user clicks on back button in the browser?我的问题是,如果用户单击浏览器中的后退按钮,我如何在购买巧克力后将用户重定向到主页? I´ve seen web pages like amazon and walmart doing this.我见过像亚马逊和沃尔玛这样的 web 页面这样做。 Thank you very much for the help.非常感谢你的帮助。

Cient side you can do this using javascript: Cient 方面,您可以使用 javascript 执行此操作:

window.location.replace("https://www.yourDomain.com");

Server side you can do the redirect by using the response object.在服务器端,您可以使用响应 object 进行重定向。 See this article for more information on server redirecting in spring boot:有关 spring 引导中服务器重定向的更多信息,请参阅本文:
A Guide To Spring Redirects Spring 重定向指南

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM