找不到Tomcat 404错误 [英] Tomcat 404 Not Found error

查看:473
本文介绍了找不到Tomcat 404错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我的Web应用程序在Eclipse&上运行良好.我的台式机上的Tomcat.当我将war文件上传到实际服务器时,无法通过以下错误消息访问所有servlet.其他JSP和HTML文件没有问题.

My web application runs fine with Eclipse & Tomcat on my desktop PC. When I uploaded the war file to the actual server, I wasn't able to access all the servlets with the following error message. Other JSP and HTML files had no problems.

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.

这是怎么引起的,我该如何解决?

How is this caused and how can I solve this?

推荐答案

您的问题是,在您的生产环境中,tomcat的前面是一个Apache httpd,它不会将/foobar形式的url的请求转发给tomcat.扩展名). Apache不知道如何处理这些URL,而是尝试将它们作为磁盘中的静态文件使用.这些文件不存在,因此它尝试执行配置错误的404规则(配置的404文件本身也丢失了-但这是另一个问题).

Your problem is that in your production environment tomcat is being fronted by an apache httpd which does not forward requests to tomcat for urls of the form /foobar (without an extension). Apache doesn't know how to deal with those URLs and tries to serve them as static files from the disk. The files are not there so it tries to execute the 404 rule which is badly configured (the configured 404 file is itself missing as well - but that's another problem).

解决方案:

  • 为所有servlet分配扩展名,并指定为apache.例如.do(就像struts一样),因此您的servlet成为/foobar.do.然后,您需要请系统管理员指定*.do进入tomcat.
  • 请您的系统管理员将apache配置为将所有请求发送到tomcat,除了静态文件.例如*.jpg*.png*.css*.js
  • Assign an extension to all your servlets and specify that to apache. E.g .do (like struts does) so your servlet becomes /foobar.do. You'll then need to ask your sysadmin to specify that *.do goes to tomcat.
  • Ask your sysadmin to configure apache to send all requests to tomcat apart of those for static files. E.g *.jpg, *.png, *.css, *.js etc

这篇关于找不到Tomcat 404错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆