Google GWT错误404

时间:2012-12-08 19:46:50

标签: java google-app-engine java-ee gwt

我正在尝试从该书中运行一个示例程序:“Google App Engine Java和GWT应用程序开发代码。”

该程序名为connactr。

该程序正在使用导入: com.google.appengine.api.labs.taskqueue.TaskOptions.Builder.url com.google.appengine.api.labs.taskqueue.Queue

那不再存在,所以我把它们改为: com.google.appengine.api.taskqueue.TaskOptions.Builder.withurl com.google.appengine.api.taskqueue。*

我也改变了代码:

Queue queue = QueueFactory.getDefaultQueue();
      queue.add(url("/updatefeedurls").payload(data,
        "application/x-java-serialized-object"));

为:

Queue queue = QueueFactory.getDefaultQueue();
      queue.add(withUrl("/updatefeedurls").payload(data,
        "application/x-java-serialized-object"));

我在旧方法的每个地方都做了这些改变。 我能够运行应用程序,没有错误,但是对于每个页面,我都收到错误404,找不到页面。

我假设withurl()方法有不同的逻辑导致错误404,但我无法找到我应该做的修复它。

为了使这项工作,我应该改变什么?

这是web.xml:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://java.sun.com/xml/ns/javaee"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee       
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"   
id="WebApp_ID"
version="2.5">


<!-- ===================== friendsService ===================== -->
<servlet>
<servlet-name>friendsService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.FriendsServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>friendsService</servlet-name>
<url-pattern>/connectr/friendsService</url-pattern>
</servlet-mapping>

<!-- ===================== messagesService ===================== -->
<servlet>
<servlet-name>messagesService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.MessagesServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>messagesService</servlet-name>
<url-pattern>/connectr/messagesService</url-pattern>
</servlet-mapping>

<!-- ===================== Login Service ===================== -->
<servlet>
<servlet-name>loginService</servlet-name>
<servlet-class>com.metadot.book.connectr.server.LoginServiceImpl</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>loginService</servlet-name>
<url-pattern>/connectr/loginService</url-pattern>
</servlet-mapping>


<!-- ===================== Login Google Servlet ===================== -->

<servlet>
<servlet-name>logingoogle</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginGoogleServlet</servlet-  
class>
 </servlet>

<servlet-mapping>
<servlet-name>logingoogle</servlet-name>
<url-pattern>/logingoogle</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>logingooglecallback</servlet-name>
<servlet-  
class>com.metadot.book.connectr.server.servlets.LoginGoogleCallbackServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>logingooglecallback</servlet-name>
<url-pattern>/logingooglecallback</url-pattern>
 </servlet-mapping>

<!-- ===================== Login Twitter Servlet ===================== -->

<servlet>
<servlet-name>logintwitter</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginTwitterServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>logintwitter</servlet-name>
<url-pattern>/logintwitter</url-pattern>
</servlet-mapping>

<servlet>
<servlet-name>logintwittercallback</servlet-name>
<servlet- 
class>com.metadot.book.connectr.server.servlets.LoginTwitterCallbackServlet</servlet-    
Class>
</servlet>

<servlet-mapping>
<servlet-name>logintwittercallback</servlet-name>
<url-pattern>/logintwittercallback</url-pattern>
</servlet-mapping>

 <!-- ===================== Login Facebook Servlet ===================== -->

<servlet>
<servlet-name>loginfacebook</servlet-name>
<servlet-class>com.metadot.book.connectr.server.servlets.LoginFacebookServlet</servlet-class>
</servlet>

<servlet-mapping>
<servlet-name>loginfacebook</servlet-name>
<url-pattern>/loginfacebook</url-pattern>
</servlet-mapping>






 </servlet>
 <servlet-mapping>
 <servlet-name>XMPPRequest</servlet-name>
 <url-pattern>/xmpprequest</url-pattern>
 </servlet-mapping>

 <security-constraint>
 <web-resource-collection>
  <url-pattern>/xmpprequest</url-pattern>
 </web-resource-collection>
 <auth-constraint>
  <role-name>admin</role-name>
  </auth-constraint>
 </security-constraint>



<filter-mapping> 
<filter-name>appstats</filter-name> 
 <url-pattern>/*</url-pattern> 
</filter-mapping> 

<servlet>
 <servlet-name>appstats</servlet-name>
  <servlet-class>com.google.appengine.tools.appstats.AppstatsServlet</servlet-class> 
</servlet>
 <servlet-mapping> 
 <servlet-name>appstats</servlet-name>
 <url-pattern>/appstats/*</url-pattern> 
 </servlet-mapping>

 <security-constraint> 
  <web-resource-collection> 
  <url-pattern>/appstats/*</url-pattern> 
  </web-resource-collection> 
  <auth-constraint> 
  <role-name>admin</role-name> 
  </auth-constraint> 
</security-constraint> -->

<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>ConnectrApp.html</welcome-file>
</welcome-file-list>


</web-app>

提前谢谢你, IDAN。

1 个答案:

答案 0 :(得分:0)

我认为withUrl要求委托Url按预期工作而不是相对位置。幸运的是,GWT提供了一种以动态方式制作整个URL的方法。

尝试使用TaskOptions getUrl()方法。使用Window.alert(url-derived-from-getUrl)并检查使用withUrl构建的网址是什么。

您可以使用

GWT.getHostPageBaseUrl();

GWT.getModuleBaseUrl();

在withUrl(Sting url)中正确构建你的url。