Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/jsp/3.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Jsp Tomcat 404未找到错误_Jsp_Tomcat_Servlets - Fatal编程技术网

Jsp Tomcat 404未找到错误

Jsp Tomcat 404未找到错误,jsp,tomcat,servlets,Jsp,Tomcat,Servlets,我的web应用程序在我的桌面PC上使用Eclipse和Tomcat运行良好。当我将war文件上载到实际服务器时,我无法访问所有servlet,并显示以下错误消息。其他JSP和HTML文件没有问题 The requested URL /HelloWorld/TryingServlet was not found on this server. Additionally, a 404 Not Found error was encountered while trying to use an Er

我的web应用程序在我的桌面PC上使用Eclipse和Tomcat运行良好。当我将war文件上载到实际服务器时,我无法访问所有servlet,并显示以下错误消息。其他JSP和HTML文件没有问题

The requested URL /HelloWorld/TryingServlet was not found on this server.

Additionally, a 404 Not Found error was encountered while trying to use an ErrorDocument to handle the request.
这是如何造成的,我如何解决这一问题?

请尝试以下url:

http://YOUR_IP:8080/HelloWorld.war/TryingServlet

HelloWorld.war
替换为war文件的实际名称…

您的问题是,在您的生产环境中,tomcat由apache httpd处理,它不会向tomcat转发格式为
/foobar
(无扩展名)的URL请求。Apache不知道如何处理这些URL,并试图将它们作为磁盘上的静态文件提供。文件不在那里,因此它尝试执行配置不正确的404规则(配置的404文件本身也丢失了,但这是另一个问题)

解决方案:

  • 为所有servlet分配一个扩展,并将其指定给apache。例如
    .do
    (就像struts那样),这样您的servlet就变成了
    /foobar.do
    。然后,您需要要求系统管理员指定
    *。do
    转到tomcat
  • 要求您的系统管理员配置apache,将所有请求发送到tomcat,而不是静态文件。例如
    *.jpg
    *.png
    *.css
    *.js

首先,您似乎有一个面向tomcat的apache httpd。我是从你的错误文件错误中得到的。您确定要访问正确的URL吗?它是什么类型的主机?戈达迪还是什么?在某些主机上,特定于webapp的servlet仅通过URL中的特定附加前缀可用,例如
/servlets
。基本上,您需要阅读其开发人员常见问题解答/指南,或联系主机支持以了解详细信息。