0

我在通过 Eclipse 和 Tomcat 部署基本 Web 应用程序时遇到了一个奇怪的问题

错误 -

SEVERE: Allocate exception for servlet DeCommServlet

java.lang.ClassNotFoundException: com.authentication.DeCommServlet
at org.apache.catalina.loader.WebappClassLoader.loadClass(WebappClassLoader.java:1714)

但是,应用程序仍会访问 DeCommServlet doPost() 方法,并且 tomcat 保持部署但出现该错误。

小服务程序:

    <servlet>
    <servlet-name>DeCommServlet</servlet-name>
    <servlet-class>com.authentication.DeCommServlet</servlet-class>
</servlet> 

<!--  Servlet Mappings -->

<servlet-mapping>
    <servlet-name>DeCommServlet</servlet-name>
    <url-pattern>/</url-pattern>
</servlet-mapping> 

servlet 类是正确的链接,但仍然出现此错误。我在任何 lib 文件夹中都没有任何内容,但是在应用程序属性中,我在 Build Path >> Libraries 添加了 Apache Tomcat Lib

有没有人见过这个?

DeCommServlet 的代码:

@WebServlet("/DeCommServlet")
public class DeCommServlet extends HttpServlet {
private static final long serialVersionUID = 1L;

/**
 * @see HttpServlet#HttpServlet()
 */
public DeCommServlet() {
    super();
    // TODO Auto-generated constructor stub
}

/**
 * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void doGet(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    System.out.println("sdf");
    System.out.println("ddd");
}

/**
 * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse
 *      response)
 */
protected void doPost(HttpServletRequest request,
        HttpServletResponse response) throws ServletException, IOException {
    // TODO Auto-generated method stub
    request.getUserPrincipal().getName();   
    response.sendRedirect("http://www.google.com"); 
}

新课程路径1

4

2 回答 2

1

这就是你的 webapp 的样子:

> DeCommGlobal
> |-->src
>      |-->com
>           |-->authentication
>                      |-->DeCommServlet.java
> |-->META-INF
> |-->WEB-INF
>     |-->classes
>     |-->lib
于 2013-08-08T21:40:47.860 回答
0

这是导致问题的部署程序集。添加了 lib 文件夹,我们可以开始了!谢谢

于 2013-09-10T20:38:22.343 回答