【发布时间】:2009-10-23 13:52:01
【问题描述】:
我一直在尝试让 GWT 与 Spring 一起工作一段时间。有没有人在 Spring 中使用官方的 Eclipse GWT 插件,并且谁设法让托管模式与该组合一起工作?
我正在使用 GWTController 通过 dispatcher-servlet.xml 初始化 GWT。由于我的 WEB-INF 不在 war 中,而是在 WebContent 文件夹中,所以我在将 Java 代码编译为 .js 时使用“-war WebContent”开关。
至于托管模式...如果我尝试通过 IDE(作为 Web 应用程序运行)运行它,我会收到“启动失败 - 无法在项目 MyProject 中找到任何主机页面。”我尝试使用 Ant 任务运行它,如下所示:
<condition property="XstartOnFirstThread" value="-XstartOnFirstThread">
<os family="mac"/>
</condition>
<condition property="XstartOnFirstThread" value="">
<not><os family="mac"/></not>
</condition>
<target name="hosted" depends="" description="Run hosted mode">
<java failonerror="true" fork="true" classname="com.google.gwt.dev.HostedMode">
<classpath>
<pathelement location="src" />
<path refid="my-client-classpath" />
</classpath>
<jvmarg value="-Xmx256M" />
<jvmarg line="${XstartOnFirstThread}" />
<arg value="-startupUrl" />
<arg value="MyPage.html" />
<arg value="my.gwt.client.Whatever" />
</java>
</target>
这导致托管模式启动,但我得到 404 而不是我的网页...
编辑:当我进入托管模式时,我看到包含已编译 Javascript 代码的文件夹,但没有其他内容。所以我的问题基本上是有人有一个很好的教程或他可以分享的设置吗?网上有很多半生不熟的信息,但我无法使它们发挥作用。
编辑 2:这是我的 .gwt.xml 文件,它非常基本:
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE module PUBLIC "-//Google Inc.//DTD Google Web Toolkit 1.7.1//EN" "http://google-web-toolkit.googlecode.com/svn/tags/1.7.1/distro-source/core/src/gwt-module.dtd">
<module rename-to='whatever'>
<!-- Inherit the core Web Toolkit stuff. -->
<inherits name='com.google.gwt.user.User' />
<!-- Inherit the default GWT style sheet. You can change -->
<!-- the theme of your GWT application by uncommenting -->
<!-- any one of the following lines. -->
<inherits name='com.google.gwt.user.theme.standard.Standard' />
<!-- <inherits name='com.google.gwt.user.theme.chrome.Chrome'/> -->
<!-- <inherits name='com.google.gwt.user.theme.dark.Dark'/> -->
<!-- Other module inherits -->
<!-- Specify the app entry point class. -->
<entry-point class='my.gwt.client.Whatever' />
<!-- Lokalizacije -->
<extend-property name="locale" values="hr" />
</module>
【问题讨论】:
-
你能把你的浏览器试图访问的网址贴出来吗?
-
URL 是 Ant 任务中的参数之一 - 在本例中为“localhost:8080/MyPage.html”,它在我正常启动 Tomcat 但在托管模式下不起作用。
-
你能发布你的模块配置文件吗?你在使用 rename-to 属性吗?
-
米格尔,我愿意,但遗憾的是,我不知道你在说什么。您指的是运行配置屏幕吗?
-
我指的是扩展名为 .gwt.xml 的文件。