GWT客户端java如何转换为HTML? [英] How does the GWT client java is converted to a HTML?

查看:96
本文介绍了GWT客户端java如何转换为HTML?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在开发一个GWT网络应用程序。我在客户端使用java编写代码。但是,当我运行该应用程序时,它显示为一个普通的HTML页面。当我编译和运行GWT应用程序时发生了什么。即Java类如何转换为HTML?此HTML代码驻留在哪里?我可以在/ war /中看到很多html。但是,没有人足够清楚我的理解。有人能帮我理解GWT编译是如何工作的吗?我已阅读了一些在线文章:

http://code.google.com/webtoolkit/doc/latest/tutorial/compile.html



这就是说:html under / war对于浏览器具体而言很重要。但是,我有兴趣找到一个包含com.google.client.ui.textbox的文本框的html。



谢谢。

解决方案

GWT不会将您的类编译为HTML,而是将其编译为JavaScript,然后依次操作DOM树你的HTML页面。除此之外,由GWT编译器生成的JavaScript大量混淆和缩小以减小大小。这就是为什么你永远不会看到实际的软件包名称,因为它们在生成的JavaScript中缩短了。如果你仍然想看到编译器的有意义的输出,你可以添加

  -style PRETTY 

OR

  -style Detailed 

添加到GWT编译器命令行中(您可以在阅读过的文档中找到更多详细信息)。

I'm developing a GWT web app. I write the code in java in client side. But, when I run the app, it appears as a plain HTML page. What is happening when I compile and run a GWT application. i.e. How does the java class gets converted to HTML? and where does this HTML code reside? I could see a lot of html in /war/. But, none were clear enough for me to understand. Could someone help me understand how GWT compilation works? I have read some online articles:

http://code.google.com/webtoolkit/doc/latest/tutorial/compile.html

This says: the html under /war is important for browser specific. But, I'm interested in finding a html which would contain "textbox" for com.google.client.ui.textbox.

Thank you.

解决方案

GWT doesn't compile your classes to HTML, instead it compiles the to JavaScript, which in turns manipulates the DOM tree of your HTML page. In addition to this, the JavaScript generated by the GWT compiler is heavily obfuscated and minified to reduce the size. That's why you never see the actual package names as they are shortened in the generated JavaScript. If you still want to see meaningful output of the compiler you can add

-style PRETTY

OR

-style DETAILED

to the GWT compiler command line (you can find more detail in the docs you've been reading).

这篇关于GWT客户端java如何转换为HTML?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆