2012-06-01 36 views
0

我有一個dyanmic web項目,分別在包de.vogella.wtp.filecounter.dao;中包含DAO FileDao和包d e.vogella.wtp.filecounter.servlets;包中的servlet FileCounter。 我試圖運行servlet並更改端口8088,因爲我的8080已被其他應用程序佔用。當我運行這個servlet我得到下面的錯誤控制檯:試圖運行我的servlet時的HTTP狀態404

Jun 1, 2012 2:39:13 PM org.apache.tomcat.util.digester.SetPropertiesRule begin 
WARNING: [SetPropertiesRule]{Server/Service/Engine/Host/Context} Setting propert 
y 'source' to 'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter' did not fi 
nd a matching property. 
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["http-bio-8088"] 
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol init 
INFO: Initializing ProtocolHandler ["ajp-bio-8010"] 
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina load 
INFO: Initialization processed in 380 ms 
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardService startInternal 
INFO: Starting service Catalina 
Jun 1, 2012 2:39:13 PM org.apache.catalina.core.StandardEngine startInternal 
INFO: Starting Servlet Engine: Apache Tomcat/7.0.27 
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["http-bio-8088"] 
Jun 1, 2012 2:39:13 PM org.apache.coyote.AbstractProtocol start 
INFO: Starting ProtocolHandler ["ajp-bio-8010"] 
Jun 1, 2012 2:39:13 PM org.apache.catalina.startup.Catalina start 
INFO: Server startup in 260 ms 

這是錯誤:

HTTP Status 404 - /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter 

-------------------------------------------------------------------------------- 

type Status report 

message /de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter 

description The requested resource (/de.vogella.wtp.filecounter/servlet/de.vogella.wtp.filecounter.servlets.FileCounter) is not available. 


-------------------------------------------------------------------------------- 

Apache Tomcat/7.0.27 

在什麼地方出了錯任何的猜測?

+0

_When我跑這個servlet我得到下面的錯誤在console_我看不到任何錯誤,你打在瀏覽器中幹了什麼,什麼是你的應用程序的上下文路徑,什麼是你的servlet映射到? –

+0

它顯示一個警告,設置屬性 y'源'爲'org.eclipse.jst.jee.server:de.vogella.wtp.filecounter'沒有fi nd一個匹配的屬性。我更新了錯誤。 – JNPW

+0

顯示你的web.xml – mprabhat

回答

1

HTTP錯誤404意味着未找到頁面或資源。 所以你只是輸入了不正確的URL。只需檢查web.xml中的URL和瀏覽器中輸入的URL即可。

在這裏,也許FileCounter類錯位。檢查一下。

0

我在做同樣的教程,並有同樣的問題。我想這是一個很常見的教程,所以我會在這裏留下我的答案。

在我的安裝中,默認情況下,Eclipse不會創建web.xml。在創建Servlet時,Eclipse使用註釋進行映射。我意外刪除了複製教程代碼時的註釋。我想你也是這樣做的。

爲了解決這個問題,我在課前加入了一個@WebServlet註解。就像這樣:

@WebServlet("/FileCounter") 
public class FileCounter extends HttpServlet { 
...