我对使用 GWT 有严重的怀疑。 GWT 声称客户端代码已编译为 JavaScript 和 HTML,但在编译代码后,我仍然在我的项目中看到客户端代码的 .class 文件。当然我在WEB-INF目录下确实有一些js和html文件,但是如果java客户端代码完全编译成js和html,为什么项目中会有.class文件?
最佳答案
如果您知道 GWT 是什么,这非常简单。根据维基百科:
GWT 应用程序可以在两种模式下运行:
- Development mode (formerly Hosted mode): The application is run as Java bytecode within the Java Virtual Machine (JVM). This mode is typically used for development, supporting hot swapping of code and debugging.
- Production mode (formerly Web mode): The application is run as pure JavaScript and HTML, compiled from the Java source. This mode is typically used for deployment.
我想您明白为什么您会在您的项目中看到 Java 字节码文件 (.class)。检查方法:启动你的项目,打开gwt生成的网页,从客户端包中删除.class文件,就不行了。但是在生产模式下它可以正常工作,因为它不依赖于某些 .class 文件。例如,负责构建 UI 的类。
关于gwt - GWT 真的是将客户端代码编译成 JavaScript 和 HTML 吗?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/9275366/