【发布时间】:2012-07-02 15:39:16
【问题描述】:
我正在尝试使用 Eclipse 在我的本地 Tomcat 上运行一个 servlet。
但我不断收到此错误,不知道该怎么做。
我实际上是在这里记录的:http://www.screenr.com/ZyD8
非常感谢!
我也将 web.xml 更改为:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID"
version="3.0"
xmlns="http://java.sun.com/xml/ns/javaee"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" >
<display-name>
TEST3
</display-name>
<welcome-file-list>
<welcome-file>
TEST3
</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>
helloServlet
</servlet-name>
<servlet-class>
HelloServlet
</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>
helloServlet
</servlet-name>
<url-pattern>
/hello
</url-pattern>
</servlet-mapping>
</web-app>
【问题讨论】:
-
Servlet 是否有包,如果有,则在 web.xml 中写入完全限定的类名
-
它在“默认包”中。但即使我在包“test.servlet”中创建它并将“test.servlet.HelloServlet”作为 web.xml 中的类名,它也会给出相同的错误