英文:
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>
通过集体智慧和协作来改善编程学习和解决问题的方式。致力于成为全球开发者共同参与的知识库,让每个人都能够通过互相帮助和分享经验来进步。
评论