【问题标题】:Can't run gwt hello world on Netbeans 7无法在 Netbeans 7 上运行 gwt hello world
【发布时间】:2012-08-01 11:55:38
【问题描述】:

美好的一天!我从 gwt 2.5 开始。我已经在 NetBeans_7 上安装了 org-netbeans-modules-gwt4nb-2.10.5.nbm。在我使用 GlassFish 3+ 在 NetBeans_7 中构建并运行了一个简单的 gwt 应用程序 (enter link description here) 后,默认浏览器 (firefox_14) 启动了相应的页面并输出空页面。有什么问题?我还在 firefox_14 上安装了 gwt 开发插件,但我得到了相同的结果。
主入口点

...
public class MainEntryPoint implements EntryPoint {

    /**
     * Creates a new instance of MainEntryPoint
     */
    public MainEntryPoint() {
    }

    /**
     * The entry point method, called automatically by loading a module that
     * declares an implementing class as an entry-point
     */
    @Override
    public void onModuleLoad() {
        final Label label = new Label("Hello, GWT!!!");
        final Button button = new Button("Click me!");

        button.addClickHandler(new ClickHandler() {

            @Override
            public void onClick(ClickEvent event) {
                label.setVisible(!label.isVisible());
            }
        });

        RootPanel.get().add(button);
        RootPanel.get().add(label);
    }
}
...

HelloGWT.html

<!doctype html>
<!--
The DOCTYPE declaration above will set the browser's rendering engine into
"Standards Mode". Replacing this declaration with a "Quirks Mode" doctype may
lead to some differences in layout.
-->
<html>
    <head>
        <meta http-equiv="content-type" content="text/html; charset=UTF-8">
        <meta name='gwt:module' content='gwt.intro.Main=gwt.intro.Main'>
        <title>Main</title>
    </head>
    <body>
        <script type="text/javascript"  src="gwt.intro.Main/gwt.intro.Main.nocache.js"></script>
    <!-- RECOMMENDED if your web app will not function without JavaScript enabled -->
    <noscript>
      <div style="width: 22em; position: absolute; left: 50%; margin-left: -11em; color: red; background-color: white; border: 1px solid red; padding: 4px; font-family: sans-serif">
        Your web browser must have JavaScript enabled
        in order for this application to display correctly.
      </div>
    </noscript>
    </body>
</html>

我收到以下警告:

  1. GWT 编译客户端代码。 警告:“com.google.gwt.dev.GWTCompiler”已弃用,将在未来的版本中删除。 请改用“com.google.gwt.dev.Compiler”。 (要禁用此警告,请将 -Dgwt.nowarn.legacy.tools 作为 JVM 参数传递。);
  2. 计算“com.google.gwt.useragent.client.UserAgentAsserter”的所有可能的重新绑定结果 重新绑定 com.google.gwt.useragent.client.UserAgentAsserter 检查规则 [WARN] 检测到与“com.google.gwt.editor.client.SimpleBeanEditorDriver”相关的警告。类路径上是否有validation-api-.jar 和validation-api--sources.jar? 指定 -logLevel DEBUG 以查看所有错误。 [WARN] 在延迟绑定规则中指定了未知类型“com.google.gwt.editor.client.SimpleBeanEditorDriver”

我一运行应用程序,就会从服务器收到以下消息:http://postimage.org/image/uf6lcczjb/

【问题讨论】:

  • 你的应用在做什么?你能告诉我们EntryPoint类吗?确保向 RootPanel 添加一些内容。
  • 是的。我不带参数调用 RootPanel(因此,这个包装了 元素)并向面板添加标签和按钮:pastie.org/4376291
  • EntryPoint 类和您的主机页面在我看来确实不错。您是否在编译期间或启动开发模式时检查是否有任何错误?如果一切正常,开发模式应该会给你一个“模块加载”的消息。
  • 我已经编辑了我的消息并指出了我从编译器收到的所有警告。

标签: gwt netbeans-7


【解决方案1】:

GWT4NB 插件似乎使用旧的 GWT 编译器类,这就是您收到警告的原因。然而,这不应该是一个问题。 404 错误表明缺少某些内容,或者您​​将浏览器指向错误的 URL。您的主机页面的名称必须与 URL 中的页面名称相匹配。由于您的主机页面名为 HelloGWT.html,因此请确保您打开的 URL 类似于:

http://127.0.0.1:8080/HelloGWT.html

对于最终构建,我建议您使用 Ant 或 Maven。查看官方 GWT 文档 Compile and run in production modeDeploy a GWT Application

【讨论】:

    【解决方案2】:

    打开 gwt.properties 文件并根据需要更改 gwt.output.dir 条目(/ 后跟条目 gwt.module 的值)。 梅齐亚诺

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2021-02-14
      • 2014-09-25
      • 1970-01-01
      • 2020-08-07
      • 1970-01-01
      • 2018-08-18
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多