Java 使用 ExtJS 进行页面重定向/刷新

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/1778072/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-12 22:32:21  来源:igfitidea点击:

Page redirect / refresh using ExtJS

javajavascriptjspjakarta-eeextjs

提问by Abdel Raoof

My Web application makes use of Ext JS & Java web technology. Due to the size and complexity of the application, I need to do a complete refresh of the page (load a different page) when user select some menu from the menu bar. What is the best what to redirect to the required page?

我的 Web 应用程序使用了 Ext JS 和 Java Web 技术。由于应用程序的大小和复杂性,当用户从菜单栏中选择某个菜单时,我需要完全刷新页面(加载不同的页面)。重定向到所需页面的最佳方法是什么?

For example, In my main menu, I have two menu Stock & Location. These two menu will take the user to different JSP files (stockmgt.jsp & locmgt.jsp) with new layouts,menu items etc.

例如,在我的主菜单中,我有两个菜单 Stock & Location。这两个菜单会将用户带到具有新布局、菜单项等的不同 JSP 文件(stockmgt.jsp 和 locmgt.jsp)。

One possibility is to use location.href in the button or menu handler. But if I do this, will I retain the session variables, and other parameters?

一种可能性是在按钮或菜单处理程序中使用 location.href。但是如果我这样做,我会保留会话变量和其他参数吗?

What are the best practices in doing these kind of redirect or page refresh?
Thanks in advance for the ideas, comment and suggestions.

进行此类重定向或页面刷新的最佳实践是什么?
在此先感谢您的想法、评论和建议。

采纳答案by jerjer

location.href will do, unless otherwise if they are on different domain.

location.href 可以,除非它们在不同的域中。

回答by jerjer

Add this to your clickable element:

将此添加到您的可点击元素:

onclick = "location.href='anotherpage.jsp'"

onclick = "location.href='anotherpage.jsp'"

For example:

例如:

< img src="blablabla.png" onclick="location.href='anotherpage.jsp'" >

<img src="blablabla.png" onclick="location.href='anotherpage.jsp'" >

回答by Zoot

These three methods will do the job (Source- MediaCollege.com):

这三种方法将完成这项工作(SourceMediaCollege.com):

<input type="button" value="Reload Page" onClick="window.location.reload()">



<input type="button" value="Reload Page" onClick="history.go(0)">



<input type="button" value="Reload Page" onClick="window.location.href=window.location.href">

If you're just looking for code to stick directly in a script, try:

如果您只是在寻找直接粘贴在脚本中的代码,请尝试:

window.location.reload()

history.go(0)

window.location.href=window.location.href