【发布时间】:2016-10-28 13:17:21
【问题描述】:
我正在尝试在 Eclipse 中进行 servlet 映射。使用注释来映射 servlet 似乎工作正常,但是当我尝试使用 web.xml 文件时,我遇到了问题。我也希望能够映射 jsp,因此我想在注释样式上使用 xml 文件。这是我在尝试将 servlet 映射添加到 web.xml 文件时遇到的错误。
'Starting Tomcat v8.0 Server at localhost'遇到了问题。 Server Tomcat v8.0 Server at localhost 启动失败。
这是我的 web.xml 文件:
<?xml version="1.0" encoding="UTF-8"?>
<web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns="http://xmlns.jcp.org/xml/ns/javaee"
xsi:schemaLocation="http://xmlns.jcp.org/xml/ns/javaee http://xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd"
id="WebApp_ID" version="3.1">
<display-name>Ryans Testing Project</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>
<servlet-name>AController</servlet-name>
<servlet-class>controller/AController</servlet-class>
</servlet>
<servlet-mapping>
<servlet-name>AController</servlet-name>
<url-pattern>/AController</url-pattern>
</servlet-mapping>
</web-app>
另外,这是我的文件结构的图像:
【问题讨论】:
-
下次您看到此一般性错误消息时遇到问题,只需查看服务器日志以获取详细答案。很有可能这是一个(相当不言自明的)
java.lang.ClassNotFoundException: controller/AController。
标签: java eclipse tomcat servlets mapping