JSNI Hello World is not working
JSNI Hello World is not working
我用JSNI做了一个简单的Hello World GWT示例。它只显示一条消息。
下面是入口点类中的代码:
public void onModuleLoad() {
// TODO Auto-generated method stub
alert("Hello World!");
}
native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
}
我看到此异常:
java.lang.reflect.InvocationTargetException
at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source)
知道为什么吗?
我创建了示例 GWT 项目并将您的代码复制到入口点,它工作正常。我认为您有一个更深层次的设置问题。我会查看您的 *.gwt.xml 文件并确保它没有格式不正确,并检查您的 GWT 库引用等。还要打开运行配置并确保它是一个 Web 应用程序。
/**
* Entry point classes define <code>onModuleLoad()</code>.
*/
public class So implements EntryPoint {
native void alert(String msg) /*-{
$wnd.alert(msg);
}-*/;
/**
* This is the entry point method.
*/
public void onModuleLoad() {
alert("Hello World!");
}
}
您可能不是在 DevMode 中运行此代码,而是在普通的 JVM 中运行此代码,GWT 无法发挥其魔力
相关文章:
- $rootScope not working
- jQuery document.ready not working
- Javascript getElementsByTagName not working?
- JQuery.val( ) not working
- Tomcat websocket is not working
- Javascript JSON.parse not working
- NodeJS Multer is not working
- Regex not working
- Ember run.debounce not working
- AngularJs 1 not working
- document.getElementById.style.backgroundImage not working
- Rxjs5, distinct() is not working
- createOscillator noteOn not working
- Javascript - .getHours() not working
- Javascript setTimeout not working | onkeydown
- MongoDB $pull not working
- Express router.use not working
- JSONP not working
- window.opener not working in chrome & IE
- Backbone + RequireJS: Collection.each() is not working