GWT:Servlet URL映射给出了一个404错误 [英] GWT: Servlet URL mapping gives a 404 error
问题描述
我已经阅读了其他GWT Servlet问题,但我仍然无法解决我的问题。我的软件包叫做Maps,它有一个名为MyService的服务(根据GWT教程设置)。 web.xml文件包含以下内容:
I have read the other GWT Servlet questions, but I'm having trouble solving my problem still. My package is called Maps, and it has a service named MyService (which was set up according to a GWT Tutorial). The web.xml file includes the following:
<servlet>
<servlet-name>MyServiceImpl</servlet-name>
<servlet-class>com.xerox.maps.maps.server.MyServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>MyServiceImpl</servlet-name>
<url-pattern>/Maps/service</url-pattern>
</servlet-mapping>
在MyService中,我有一行:
In MyService, I have the line:
@RemoteServiceRelativePath("service")
public interface MyService extends RemoteService { ...
但是,当我尝试进行RPC调用时,会出现错误。错误的详细信息说它是一个404 HTTP错误。我怎样才能解决这个问题,以确保映射是正确的?
However, when I try to make an RPC call, there is an error thrown. The details of the error say that it is a 404 HTTP error. How can I fix this, to make sure that the mapping is correct?
编辑7.27
MyService.java包含注释:
MyService.java contains the annotation:
@RemoteServiceRelativePath("service")
而web.xml包含:
And web.xml contains:
<servlet-name>MyServiceImpl</servlet-name>
<url-pattern>/com.x.maps.Maps/service</url-pattern>
如果我使用FireBug跟踪XHR,它会告诉我有一个对com.x的调用。 maps.Maps
If I follow the XHR with FireBug, it shows me that there is a call to com.x.maps.Maps
推荐答案
404当GWT错误地推断服务端点路径时,通常不会引发此错误。尝试删除 @RemoteServiceRelativePath(service)
并重新编译并检查,如果这样做不起作用,则手动查找服务的URL端点(通过从浏览器中敲击可能的路径错误更改为500内部错误),然后将正确的路径作为参数提供给 @RemoteServiceRelativePath(correct / path)
。我会立即尝试的几个试验是 @RemoteServiceRelativePath(/ Maps / service)
和 @RemoteServiceRelativePath(Maps / service)
没有斜杠
404 Not found is thrown usually when service endpoint path is inferred wrongly by GWT. Try removing @RemoteServiceRelativePath("service")
and recompile and check, If that does not work find out the URL endpoint of the service manually (by hitting likely paths from a browser till the error changes to 500 internal error) and then give the correct path as argument to @RemoteServiceRelativePath("correct/path")
. Few trials I would try right away is @RemoteServiceRelativePath("/Maps/service")
and @RemoteServiceRelativePath("Maps/service")
without the slash
这篇关于GWT:Servlet URL映射给出了一个404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!