调试时,我使用 mysql 数据库的 gwt 应用程序在 Eclipse 中正常运行。当我在 tomcat 上运行它时,它会正确显示,但是当我单击一个生成 RPC 的按钮(执行 servlet 并联系数据库)时,我得到一个错误。我检查了我的 tomcat 日志,单击按钮时看到 404 错误:
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:32:39 +0200] "GET /Bazica/war/Bazica.html HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:32:39 +0200] "GET /Bazica/war/Bazica.css HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:32:39 +0200] "GET /Bazica/war/bazica/bazica.nocache.js HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:32:39 +0200] "GET /Bazica/war/bazica/ F0C186B415ADBD43522C686552368517.cache.html HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:32:39 +0200] "GET /Bazica/war/bazica/gwt/standard/images/hborder.png HTTP/1.1" 304 -
0:0:0:0:0:0:0:1 - - [22/Jul/2010:10:33:29 +0200] "POST /Bazica/war/bazica/greet HTTP/1.1" 404 1024
我猜这是 web.xml 文件和 url 模式的问题。我想我不明白这个 url 模式,它应该指向哪里?
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>greetServlet</servlet-name>
<servlet-class>com.test.baze.server.GreetingServiceImpl</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>greetServlet</servlet-name>
<url-pattern>/bazica/greet</url-pattern>
</servlet-mapping>
<!-- Default page to serve -->
<welcome-file-list>
<welcome-file>Bazica.html</welcome-file>
</welcome-file-list>
</web-app>
我的界面有一个注释 RemoteServiceRelativePath("greet"),我认为它是相关的:
package com.test.baze.client;
import com.google.gwt.user.client.rpc.RemoteService;
import com.google.gwt.user.client.rpc.RemoteServiceRelativePath;
/**
* The client side stub for the RPC service.
*/
@RemoteServiceRelativePath("greet")
public interface GreetingService extends RemoteService {
String greetServer(String name) throws IllegalArgumentException;
}
我尝试将 url-pattern 更改为我的服务实现 /WEB-INF/classes/com/test/baze/server 的文件夹,但我的应用程序挂起并且没有任何消息。你能帮我改变我的web.xml或某事吗?否则让我的应用程序在 Tomcat 上运行。肿瘤坏死因子。