如何在使用GWT 2.5时在HTML中编写(启用)Java代码? [英] How to write(enable) Java code in HTML while using GWT 2.5?

查看:137
本文介绍了如何在使用GWT 2.5时在HTML中编写(启用)Java代码?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已经开始利用GWT 2.5。 GWT 2.5最酷的功能是能够直接在我们的HTML页面中编写Java代码,如下所示:

I've started taking advantage of GWT 2.5. The coolest feature of GWT 2.5 was the ability to write Java code directly in our HTML pages like so:

<script type="text/java">
   String helloWorld = "Hello world";
   Window.alert(helloWorld);
</script>

关键是使用 ServletFilter 服务器端。这个 ServletFilter 使用GWT编译器将这个Java代码编译成Javascript,并将其注入到返回给客户端的HTML中。

The trick is to use a ServletFilter on the server side. This ServletFilter uses the GWT compiler to compile this java code into Javascript and inject it into the HTML returned to the client.

我无法弄清楚如何在 web.xml 中过滤它,或者如何将信息传递给编译器。我该如何做到这一点?

I am unable to figure out how to filter this in web.xml or how to pass information to the compiler. How can I do this?

推荐答案

这是 Google I / O 2012 - Google Web Toolkit的历史和未来。这是Ray Cromwell发布的幻灯片

Here is the Google I/O 2012 - The History and Future of Google Web Toolkit you are referring too. And here are the slides posted by Ray Cromwell.

这篇关于如何在使用GWT 2.5时在HTML中编写(启用)Java代码?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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