2011-07-05 33 views
0

我正在GWT上测试一个示例web应用程序,我已经下载了所有的SDK和eclipse上的插件,我设计了一个小型窗体,用户几乎不需要输入,当用户点击按钮,它正在调用使用RPC服务, 现在它给错误“无法打电话到GWT服务

**errorcom.google.gwt.user.client.rpc.StatusCodeException: 404 <html> 
<head> 
<meta http-equiv="Content-Type" content="text/html; charset=ISO-8859-1"/> 
<title>Error 404 NOT_FOUND</title> 
</head> 
<body><h2>HTTP ERROR: 404</h2><pre>NOT_FOUND</pre> 
<p>RequestURI=/com.mpigeon.foofy.signup.SignUp/SignUpservlet</p><p><i><small><a href="http://jetty.mortbay.org/">Powered by Jetty://</a>** 

”。 也就是说,它根本不连接到服务,我真的在这里坚持帮助我找出错误。 我正在分享下面

的代码,这是signup.gwt.xml文件

<?xml version="1.0" encoding="UTF-8"?> 
<module rename-to='foofysignup'> 
    <inherits name="com.google.gwt.user.User"/> 
    <inherits name="com.google.gwt.user.theme.standard.Standard"/> 
    <entry-point class="com.mpigeon.foofy.signup.client.SignUp"/> 

    <source path='client'/> 
    <source path='shared'/> 

</module> 

的web.xml

<?xml version="1.0" encoding="UTF-8"?> 
<!DOCTYPE web-app 
    PUBLIC "-//Sun Microsystems, Inc.//DTD Web Application 2.3//EN" 
    "http://java.sun.com/dtd/web-app_2_3.dtd"> 

<web-app> 

    <!-- Servlets --> 
    <servlet> 
    <servlet-name>fsignup</servlet-name> 
    <servlet-class>com.mpigeon.foofy.signup.server.SignupServiceImpl</servlet-class> 
    </servlet> 

    <servlet-mapping> 
    <servlet-name>fsignup</servlet-name> 
    <url-pattern>/foofysignup/SignUpservlet</url-pattern> 
    </servlet-mapping> 

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

</web-app> 

服务文件接口:

import com.google.gwt.user.client.rpc.RemoteService; 
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath; 
import com.mpigeon.foofy.signup.shared.SignUpFields; 
@RemoteServiceRelativePath("SignUpservlet") 
public interface SignupService extends RemoteService { 
    public String StoreSignUp(SignUpFields obj) throws IllegalArgumentException; 

} 

注册。 html

<!doctype html> 
<html> 
    <head> 
     <meta http-equiv="content-type" content="text/html; charset=UTF-8"> 

     <!--                --> 
     <!-- Consider inlining CSS to reduce the number of requested files --> 
     <!--                --> 
     <link type="text/css" rel="stylesheet" href="SignUp.css"> 

     <!--           --> 
     <!-- Any title is fine       --> 
     <!--           --> 
     <title>Wrapper HTML for SignUp</title> 

     <!--           --> 
     <!-- This script loads your compiled module. --> 
     <!-- If you add any GWT meta tags, they must --> 
     <!-- be added before this line.    --> 
     <!--           --> 
     <script language="javascript" src="/com.mpigeon.foofy.signup.SignUp.nocache.js"></script> 

    </head> 

    <!--           --> 
    <!-- The body can have arbitrary html, or  --> 
    <!-- we leave the body empty because we want --> 
    <!-- to create a completely dynamic ui   --> 
    <!--           --> 
    <body> 

     <!-- OPTIONAL: include this if you want history support --> 
     <iframe id="__gwt_historyFrame" style="width:0;height:0;border:0"></iframe> 
    <div id="signupdiv"></div> 
    </body> 
</html> 

回答

0

如果更换

@RemoteServiceRelativePath("SignUpservlet") 

@RemoteServiceRelativePath("../foofysignup/SignUpservlet") 

的RPC请求应该工作。这不是一个好的解决方案,但它至少起作用。

正如Terrell指出你的应用程序正在从/com.mpigeon.foofy.signup.SignUp/加载,但由于你的重命名属性你的应用程序应该从/foofysignup/加载。这可能是由您的WebContent文件夹中的旧文件引起的。

您可以发布您的SignUp.html吗?

+0

嗨,彼得,我已经更新signup.html页面 –

+0

感谢彼得,我已经取代代码其工作正常,但基本上我们不应该提供绝对路径权利 –

+0

我会期望'src =“foofysignup/com.mpigeon.foofy.signup.SignUp.nocache.js”'而不是'src =“/ com.mpigeon.foofy.signup.SignUp.nocache.js”' – Peter

0

自从将<module rename-to='foofysignup'>添加到gwt.xml以来,你已经完成了GWT编译吗?

从这个错误似乎您的应用希望的servlet来默认完全合格的模块名称下映射:RequestURI=/com.mpigeon.foofy.signup.SignUp/SignUpservlet

+0

嗨,感谢您的建议,我试着编译项目,它给出了相同的错误 –