2013-12-09 71 views
0

我对GWT编程颇为陌生,但我已经用Java编写了很长一段时间!RPC调用的Servlet映射

我用RPC调用创建了一个小应用程序,但它不起作用。

当我点击按钮与将开始呼叫,我只得到控制台上显示以下信息:

[WARN] 404 - POST /wps_akt/student (127.0.0.1) 1401 bytes 
    Request headers 
     Host: 127.0.0.1:8888 
     Connection: keep-alive 
     Accept: */* 
     User-Agent: Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/31.0.1650.63 Safari/537.36 
     Accept-Encoding: gzip,deflate,sdch 
     Accept-Language: de-DE,de;q=0.8,en-US;q=0.6,en;q=0.4 
     Content-Length: 137 
     X-GWT-Module-Base: http://127.0.0.1:8888/wps_akt/ 
     X-GWT-Permutation: HostedMode 
     Origin: http://127.0.0.1:8888 
     Content-Type: text/x-gwt-rpc; charset=UTF-8 
     Referer: http://127.0.0.1:8888/Wps_akt.html?gwt.codesvr=127.0.0.1:9997 
    Response headers 
     Content-Type: text/html; charset=iso-8859-1 
     Content-Length: 1401 

的web.xml文件看起来是这样的:

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



    <!-- Servlets --> 
    <servlet> 
    <servlet-name>StudentServiceImpl</servlet-name> 
    <servlet-class>at.htlpinkafeld.wps.server.StudentServiceImpl</servlet-class> 
    </servlet> 

    <servlet-mapping> 
    <servlet-name>StudentServiceImpl</servlet-name> 
    <url-pattern>/student</url-pattern> 
    </servlet-mapping> 


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

</web-app> 

谢谢寻求帮助 Stefan

回答

2

@RemoteServiceRelativePath中的GWT-RPC路径相对于GWT.getModuleBaseURL(),即GWT产生* .nocache.js和.cache。文件(该文件夹以您的GWT模块名称或* .gwt.xml文件中的rename-to属性命名)。

因此,您的<servlet-mapping>应该使用/wps_akt/student而不仅仅是/student

如果你想使用/student,那么你就必须要调整你的@RemoteServiceRelativePath阅读"../student"(假设GWT编译器接受它)或明确设置的路径(您铸造服务ServiceDefTarget并调用setServiceEntryPoint你映射的网址你的servlet为。