我正在學習Lars Vogel的http://www.vogella.com/articles/EclipseWTP/article.html教程,我被404錯誤困住了。 所以我在Eclipse中創建了一個Dynamic Web Project,然後根據教程創建了FileDao.java和FileCounter.java。和Eclipse生成對我來說是web.xml文件,那就是:Servlet給出了404(Eclipse + Tomcat)
<?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>
我使用Tomcat 6.0,我選擇了動態Web模塊版本2.5在創建項目。
如何訪問Web應用程序(URL)?日誌中的任何內容? – home
什麼是servlet類的源代碼?你部署了webapp嗎?你爲webapp選擇了什麼上下文路徑?你在瀏覽器的地址欄中輸入什麼URL來調用servlet? –
現在我搜索了更多,這裏是我發現的:我將/從/ FileCounter的網址模式更改爲* .do,現在它工作正常!你能解釋我做了什麼嗎? 關於評論:我通過瀏覽器訪問Web應用程序,輸入http:// localhost:8080/de.vogella.wtp.filecounter/FileCounter。除此之外,我不知道在哪裏查找日誌,如何部署webapp以及什麼是上下文路徑 - 我只是通過Eclipse在服務器上運行應用程序。 – Scadge