我在使用 GWT-RPC 时遇到了一个奇怪的问题。我设置了一个工作正常的 Async
RPC 处理程序。但是当我运行我的服务器时(使用 ant devmode
)我收到以下警告:
[WARN] Module declares a servlet class 'x.y.server.LoginServiceImpl'
with a mapping to '/login/login', but the web.xml has no corresponding mapping
明确地说,在我的代码中没有任何地方指定“/login/login”。我只想使用 /login。为什么要添加两次?它几乎看起来像一个 GWT 错误。这是配置的其余部分:
我的 web.xml servlet-mapping
看起来像这样:
<servlet-mapping>
<servlet-name>LoginServiceImpl</servlet-name>
<url-pattern>/login</url-pattern>
</servlet-mapping>
我的模块文件有以下内容:
<servlet path="/login" class="x.y.server.LoginServiceImpl" />
那么,为什么我会收到关于 /login/login 的警告,而它在任何地方都没有定义?感谢任何帮助,谢谢。
-tjw
最佳答案
您可能在 .gwt.xml 文件中将 rename-to
属性定义为:
<module rename-to='login'>
您的登录服务(接口(interface)!)可能包含注释
@RemoteServiceRelativePath("login")
结果路径 (即客户端调用的路径) 然后是“/login/login”。
我不确定,如果你能轻松实现“/login”,但你可以尝试的是:
LoginServiceAsync service = GWT.create(LoginService.class);
ServiceDefTarget serviceDefTarget = (ServiceDefTarget) service;
serviceDefTarget.setServiceEntryPoint(GWT.getHostPageBaseURL() + "login");
我还没有测试过这个,所以这可能需要一点点调整(?)。来自 ServiceDefTarget 的 Javadoc:
/**
* An interface implemented by client-side RPC proxy objects. Cast the object
* returned from {@link com.google.gwt.core.client.GWT#create(Class)} on a
* {@link RemoteService} to this interface to initialize the target URL for the
* remote service.
*/
关于java - GWT RPC 警告 : servlet has mapping, 但 web.xml 没有对应的映射,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/5490500/