GWT第一个示例HelloWorld

app目录结构如下:

HelloWorld.gwt.xml代码:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 2.5.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/2.5.1/distro-source/core/src/gwt-module.dtd">
<module rename-to="helloworld">
	<inherits name="com.google.gwt.user.User" />
	<source path="client" />
	<entry-point class="com.example.myproject.client.HelloWorld" />
</module>

HelloWorld代码:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>HelloWorld</title>
    <script type="text/javascript" language="javascript" src="helloworld/helloworld.nocache.js"></script>
  </head>

  <body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

  </body>
</html>

HelloWorld.html代码:

<!doctype html>
<html>
  <head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8">
    <title>HelloWorld</title>
    <script type="text/javascript" language="javascript" src="helloworld/helloworld.nocache.js"></script>
  </head>

  <body>
    <iframe src="javascript:''" id="__gwt_historyFrame" tabIndex='-1' style="position:absolute;width:0;height:0;border:0"></iframe>

  </body>
</html>

流程总结:

1、  通过gwt工具创建web application

2、  通过gwt插件创建Module,此过程会生成HelloWorld.gwt.xml

3、  通过gwt插件创建Entry Point Class,此过程会生成HelloWorld.java

4、  通过gwt插件创建Html Page,此过程会生成HelloWorld.html

5、  在项目上右键——>Google——>GWT Compilegwt模块进行编译,此过程会在war目录下生成编译后文件(主要为helloworld目录下htmljs文件)。

6、  在项目上右键——>Run As——>Web Application,双击Development Mode下的URL可以进行预览页面效果。

7、  将项目下的war目录复制到tomcatwebapps目录下,启动tomcat后调用http://localhost:8080/war/HelloWorld.html可以查看页面效果。

 

注意:

1、HelloWorld.gwt.xml<module>标签下增加rename-to="helloworld"

2、HelloWorld.html文件中的src=".nocache.js"修改为src="helloworld/helloworld.nocache.js"


  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值