2017-06-13 89 views
0

我想在Tomcat服務器上的Eclipse中運行動態Web項目。但是,我收到錯誤原始服務器未找到目標資源的當前表示,或者不願意透露該資源存在。在運行該項目時運行。該項目的名稱是DBAccessEclipse Tomcat錯誤

我的web.xml位於WebContent \ WEB-INF在我的項目中。

<?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>DBAccess</display-name> 
    <servlet> 
    <servlet-name>acessor</servlet-name> 
    <servlet-class>dbaccess.servlet.DatabaseAccessor</servlet-class> 
    </servlet> 
    <servlet-mapping> 
    <servlet-name>acessor</servlet-name> 
    <url-pattern>/DBAccess/*</url-pattern> 
    </servlet-mapping> 
</web-app> 

我的servlet類位於下的src \ DBACCESS \ servlet的在我的項目。

package dbaccess.servlet; 

import javax.servlet.http.HttpServlet; 
import javax.servlet.http.HttpServletRequest; 
import javax.servlet.http.HttpServletResponse; 

    public class DBAccessorServlet extends HttpServlet { 

     private static final long serialVersionUID = -134532546577657L; 

     @Override 
     protected void doGet(HttpServletRequest req, HttpServletResponse resp) 
     { 
      System.out.println("The GET"); 
     } 

     @Override 
     protected void doPost(HttpServletRequest req, HttpServletResponse resp) 
     { 
      System.out.println("The POST"); 
     } 

     @Override 
     protected void doPut(HttpServletRequest req, HttpServletResponse resp) 
     { 
      System.out.println("The PUT"); 
     } 

    } 

我該如何解決問題?

回答

0

<servlet-class>dbaccess.servlet.DatabaseAccessor</servlet-class>至少應該更改爲<servlet-class>dbaccess.servlet.DBAccessorServlet</servlet-class>

+0

哎呀!錯過了我的代碼中的錯字。我解決了它,但仍然得到相同的錯誤。 ** \t 存取 \t dbaccess.servlet.DBAccessorServlet \t 存取 \t /DBACCESS/* ** – Krash

+0

是'DBAccessorServlet.class'在WEB-INF /類/ DBACCESS/servlet的/? –