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

huangapple go评论61阅读模式
英文:

Redirect user to HomePage after buying

问题

我正在使用Reactjs进行用户界面开发,并在后端使用Java和Spring Boot。

我的问题是,当用户购买巧克力后,如果用户在浏览器中单击返回按钮,如何将用户重定向到首页,仅供举例说明?我看到亚马逊和沃尔玛等网页可以做到这一点。

非常感谢您的帮助。

英文:

I am working with Reactjs in the UI and Java with Spring Boot in the Back End,

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.
Thank you very much for the help.

答案1

得分: 0

客户端可以使用 JavaScript 来执行此操作:

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

服务器端可以使用响应对象来执行重定向。有关在 Spring Boot 中进行服务器重定向的更多信息,请参阅此文章:
A Guide To Spring Redirects

英文:

Cient side you can do this using javascript:

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

Server side you can do the redirect by using the response object. See this article for more information on server redirecting in spring boot:
<br><a href="https://www.baeldung.com/spring-redirect-and-forward">A Guide To Spring Redirects</a>

huangapple
  • 本文由 发表于 2020年8月1日 05:55:11
  • 转载请务必保留本文链接:https://go.coder-hub.com/63199568.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定