Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/java/320.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
Java Servlet提供404(Eclipse和Tomcat)_Java_Eclipse_Tomcat - Fatal编程技术网

Java Servlet提供404(Eclipse和Tomcat)

Java Servlet提供404(Eclipse和Tomcat),java,eclipse,tomcat,Java,Eclipse,Tomcat,我正在学习Lars Vogel的教程,但我遇到了404错误。 因此,我在Eclipse中创建了一个动态Web项目,然后根据教程创建了FileDao.java和FileCounter.java。Eclipse为我生成了一个web.xml文件,如下所示: <?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http:/

我正在学习Lars Vogel的教程,但我遇到了404错误。 因此,我在Eclipse中创建了一个动态Web项目,然后根据教程创建了FileDao.java和FileCounter.java。Eclipse为我生成了一个web.xml文件,如下所示:

<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" id="WebApp_ID" version="2.5">
  <display-name>de.vogella.wtp.filecounter</display-name>
  <welcome-file-list>
    <welcome-file>index.html</welcome-file>
    <welcome-file>index.htm</welcome-file>
    <welcome-file>index.jsp</welcome-file>
    <welcome-file>default.html</welcome-file>
    <welcome-file>default.htm</welcome-file>
    <welcome-file>default.jsp</welcome-file>
  </welcome-file-list>
  <servlet>
    <description></description>
    <display-name>FileCounter</display-name>
    <servlet-name>FileCounter</servlet-name>
    <servlet-class>de.vogella.wtp.filecounter.servlets.FileCounter</servlet-class>
  </servlet>
  <servlet-mapping>
    <servlet-name>FileCounter</servlet-name>
    <url-pattern>/FileCounter</url-pattern>
  </servlet-mapping>
</web-app>

de.vogella.wtp.filecounter
index.html
index.htm
index.jsp
default.html
default.htm
default.jsp
文件计数器
文件计数器
de.vogella.wtp.filecounter.servlets.filecounter
文件计数器
/文件计数器

我正在使用Tomcat 6.0,在创建项目时选择了动态web模块版本2.5。

您试图访问的URL是什么。。。试一试

http://localhost:8080/<Include Your Project Name>/FileCounter
http://localhost:8080//FileCounter

如何访问web应用程序(URL)?日志中有什么吗?servlet类的源代码是什么?你部署了webapp吗?您为webapp选择了什么上下文路径?您在浏览器的地址栏中键入了什么URL来调用servlet?现在我搜索了更多内容,我发现:我将URL模式从/FileCounter更改为*.do,现在它可以正常工作了!你能解释一下我做了什么吗?关于评论:我通过浏览器访问web应用程序,键入。除此之外,我不知道在哪里可以找到日志,如何部署webapp以及什么是上下文路径——我只是通过Eclipse在服务器上运行应用程序。这就是我正在做的!我的项目名为de.vogela.wtp.filecounter,我正在访问localhost:8080/de.vogela.wtp.filecounter/FileCounterFirst检查您的应用程序是否已部署在Tomcat的WebApps文件夹中。我猜war的名称与项目名不同。检查Tomcat的webapp文件夹中的文件夹名称。