1.动态,可重用的UI组件
GWT提供的组件库使用户可以很容易的开发出漂亮的UI, 每个组件对应于GWT的一个类。在本文的第二部分会比较详细的介绍GWT对UI的支持。
2.简单的RPC调用
使用GWT,可以方便的实现客户端和服务器端的通信,特别是使得异步通信变的非常简单。在本文的后面部分将对利用GWT进行RPC调用进行详细介绍。
3.更加方便的调试
由于在开发阶段不需要生成HTML截面,用户开发的代码实际上是在JVM上运行的,这样用户就可以用传统的调试Java代码的方法对程序进行调试,从而加快了调试的速度,减少了软件开发的时间。
4.浏览器兼容性
在大多数情况下,用GWT开发出来的程序会支持IE、Firefox、Mozilla、Safari和Opera,用户在开发的时候不必担心浏览器的兼容性问题。而浏览器的兼容性问题也是用直接用Javascript进行Ajax应用开发所面临的一个另程序员棘手问题。
5.可扩展性
如果你觉得GWT提供的API不能满足需求,你可以利用JSNI将Javascript语句直接嵌入至Java代码中。
Google Web Toolkit Architecture
GWT has four major components: a Java-to-JavaScript compiler, a "hosted" web browser, and two Java class libraries:
- GWT Java-to-JavaScript Compiler
The GWT Java-to-JavaScript compiler translates the Java programming language to the JavaScript programming language. You use the GWT compiler to run your GWT applications in web mode. - GWT Hosted Web Browser
The GWT Hosted Web Browser lets you run and execute your GWT applications in hosted mode, where your code runs as Java in the Java Virtual Machine without compiling to JavaScript. To accomplish this, the GWT browser embeds a special browser control (an Internet Explorer control on Windows or a Gecko/Mozilla control on Linux) with hooks into the JVM. - JRE emulation library
GWT contains JavaScript implementations of the most widely used classes in the Java standard class library, including most of the java.lang package classes and a subset of the java.util package classes. The rest of the Java standard library isn't supported natively within GWT. For example, packages likejava.io
don't apply to web applications since they access the network and local file system. - GWT Web UI class library
The GWT web UI class library is a set of custom interfaces and classes that let your create web browser "widgets," like buttons, text boxes, images, and text. This is the core user interface library used to create GWT applications.