[英]Servlet Mapping Tomcat Error Eclipse
我正在嘗試在 Eclipse 中進行 servlet 映射。 Working with annotations to map the servlets seems to be working fine, but when I try to use the web.xml file I am getting problems. 我也希望能夠使用 map jsp,因此我想在注釋樣式上使用 xml 文件。 這是我在嘗試將 servlet 映射添加到 web.xml 文件時遇到的錯誤。
這是我的 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>
另外,這是我的文件結構的圖像:
<servlet-class>
標記只能采用完全限定的 class 名稱。 所以這樣做
<servlet>
<servlet-name>AController</servlet-name>
<servlet-class>controller.AController</servlet-class>
</servlet>
其中controller
是 package 名稱。
我也希望能夠使用 map jsp,因此我想在注釋樣式上使用 xml 文件。
這是 Servlet 3.0 規范所說的:
10.13 包含 web.xml 部署描述符
如果 web 應用程序不包含任何 Servlet、過濾器或聲明偵聽器組件或使用注釋,則不需要包含 web.xml。 換句話說,僅包含 static 文件或 JSP 頁面的應用程序不需要 web.Z0F635D5ZE0F38764F to be present。
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.