在 Eclipse 中运行 GWT 程序时出现 404 错误。似乎与 servlet 映射有关

发布于 2024-12-23 17:52:38 字数 1844 浏览 2 评论 0原文

我有一个 GWT 项目,已经运行良好数周了。昨天打开代码时,我发现代码中有数十个红色大错误。我以前见过这种情况发生,并且在经历了很多挫败之后了解到,我需要做的就是清理项目,让 Eclipse 再次开心起来,所以我就这么做了。美好的。

然而,当我运行这个东西时,我收到一个 404 错误,内容如下: 类型 状态报告 消息 /LittleRedGarden/littleredgarden/greet 描述 请求的资源(/LittleRedGarden/littleredgarden/greet)不可用。

该消息在 Eclipse 的控制台中以 HTML 形式编写。

我将在底部完整插入我的 web.xml 文件,但它似乎指向上面提到的路径。我应该说 web.xml 文件是由 Eclipse 构建的,没有我的任何监督,并且正如我所说,到目前为止一直运行良好。

我从哪里开始寻找解决方案?

谢谢。 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.ducksstory.littleredgarden.server.GreetingServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
    <url-pattern>/littleredgarden/greet</url-pattern>
  </servlet-mapping>

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

</web-app>

这是 GreetingService.java:

package com.ducksstory.littleredgarden.client;

import com.ducksstory.littleredgarden.shared.QuestionStrings;
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;
    QuestionStrings getQuestion(int i);
    String[] getMainImages();
}

I have a GWT project which has been working fine for many weeks. On opening the code yesterday I found dozens of big red errors in my code. I've seen this happen before and have learnt, after much frustration, that all I need to is clean the project for Eclipse to be happy again, so I did that. Fine.

However, when I run the thing, I get a 404 error saying this:
type Status report
message /LittleRedGarden/littleredgarden/greet
description The requested resource (/LittleRedGarden/littleredgarden/greet) is not available.

The message gets written in HTML in the console in Eclipse.

I'll insert my web.xml file in full at the bottom, but it seems to point to the paths mentioned above ok. I should say that the web.xml file was built by Eclipse without any supervision from me, and as I say, has been working fine until now.

Where do I start looking for a solution to this?

Thanks. web.xml contents here:

<?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.ducksstory.littleredgarden.server.GreetingServiceImpl</servlet-class>
  </servlet>

  <servlet-mapping>
    <servlet-name>greetServlet</servlet-name>
    <url-pattern>/littleredgarden/greet</url-pattern>
  </servlet-mapping>

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

</web-app>

Here's GreetingService.java:

package com.ducksstory.littleredgarden.client;

import com.ducksstory.littleredgarden.shared.QuestionStrings;
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;
    QuestionStrings getQuestion(int i);
    String[] getMainImages();
}

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

狼性发作 2024-12-30 17:52:38

我只是通过重新启动 Eclipse 就解决了这个问题。真是浪费时间!感谢您尝试提供帮助。

I've fixed this just by restarting Eclipse. What a waste of time! Thanks for trying to help.

硬不硬你别怂 2024-12-30 17:52:38

据我所知,您的 web.xml 文件没有 pbm。但您可以检查客户端包中编写的服务文件。在您的情况下,您的服务文件名应该是 GreetingService.java 。检查该文件是否使用了正确的注释

@RemoteServiceRelativePath("问候")

如果这也适合您的文件,那么您可以下载一个示例 gwt 项目并进行比较。如果我错了请纠正我..

Upto my knowledge there is no pbm with your web.xml file. But you may check with your service file written in the client package. In your case your service file name should be GreetingService.java . Check in that file whether you are used the proper annotation

@RemoteServiceRelativePath("greet")

If this one also fine with your file then you can download a sample gwt project and do the comparison. Correct me if i'm wrong..

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文