Tomcat通过Servlet给出404错误 [英] Tomcat giving 404 error with servlets

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

问题描述

我已经使用Tomcat 7Oracle JDK 1.7NeatBeans 7.3开发了Java Web应用程序.我的应用程序在本地PC上运行,没有任何错误.

I have developed a Java web application using Tomcat 7 and Oracle JDK 1.7 with NeatBeans 7.3. My application runs on my local pc without any errors.

但是在托管应用程序之后,我无法访问servlet.它给我404错误.我没有在应用程序中使用web.xml映射servlet.我用了annotation.

But after i hosted my application, I can't access servlets. It is giving me 404 error. I'm not used web.xml in my application to map servlets. I used annotation for it.

托管服务器使用Tomcat 7Open JDK 1.7.

可能是什么问题?我该如何解决?

What could be the issue ? How can i solve this ?

新更新

我购买主机的地方给了我cPanel上传文件.没有位置可以上传war文件,也不能将文件上传到tomcat的webapps控制器中.所以我将文件上传到public_html目录.我认为这可能是问题.因为当我尝试访问像www.mysite.com/A这样的servlet时,服务器会在root directoy中搜索它.但恰好它不在那儿.因此会显示404错误.

The place where i have purchased hosting gave me cPanel to upload files. There is no place to upload war file or place to upload files in to webapps director in tomcat. so i uploaded files in to public_html directory. i think this may be the issue. because when i'm trying to access servlet like www.mysite.com/A , server search for this in root directoy. but acctually it is not there. so it gives 404 error.

我认为这可能是问题所在.有什么建议吗?

I thnik this may be the issue. Any suggesions ?

已更新

注释如下所示

@WebServlet(name = "AddCustomer", urlPatterns = {"/AddCustomer"})

DropBox 下载Servlet.

Download Servlet from DropBox.

目录结构.

推荐答案

在将项目部署到tomcat中之后,如果位置中存在这些类,则请登录"tomcat7 \ work \ Catalina \ localhost \您的应用程序".如果有课程,那应该不是问题.

After deploying your project in to tomcat check in to "tomcat7\work\Catalina\localhost\your app" if the classes are present into the location. If classes are there then it should not be the issue.

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

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