本文介绍了GWT片段标识符在宿主模式下工作,而不是在编译模式下(Tomcat)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
下面的代码在托管/调试模式下运行,但在Tomcat中部署时不起作用。
History.addValueChangeHandler(new ValueChangeHandler< String>(){
@Override
public void onValueChange ValueChangeEvent< String>事件){
//调用更新模型,最终应用程序将显示相应的视图...
}
});
我上面的代码负责捕获事件,当用户在浏览器中输入类似这样的内容时: p>
在托管模式下工作良好,但在Tomcat中部署并通过浏览器访问时:
显示空白页。
编辑:除非gwt应用程序第一次加载并键入FI作品。 >解决方案
请阅读: 当你加载,您在历史事件发生后注册了您的历史记录处理程序。
您需要在注册后调用 History.fireCurrentHistoryState()
,然后才会触发。历史处理程序重新启动事件。
I have this code below which works when running in hosted/debug mode however it does not work when deployed in Tomcat.
History.addValueChangeHandler(new ValueChangeHandler<String>() {
@Override
public void onValueChange(ValueChangeEvent<String> event) {
// call update model, and eventually app will show the appropriate view...
}
});
I code above responsibility is to catch the event when user type something like this in the browser:
http://http://127.0.0.1:8888/index.html?gwt.codesvr=127.0.0.1:9997#user123
Works well in hosted mode, but when deployed in Tomcat and accessed via the browser:
http://127.0.0.1:8888/index.html#user123
it shows blank page.
EDIT: Unless gwt app is first loaded and typing FI works.
解决方案
Please read this: What is need History.fireCurrentHistoryState() in GWT History?
When you load http://127.0.0.1:8888/index.html#user123 for the first time, you registered your history handler after the history event has already happened. If you reload the page then it will fire.
You need to call History.fireCurrentHistoryState()
after you registered the history handler to "re-fire" the event.
这篇关于GWT片段标识符在宿主模式下工作,而不是在编译模式下(Tomcat)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!