Java:启动Servlet的第1行中出现异常

问题描述 投票:2回答:1

我正在使用Tomcat 9.0.30,JDK 8和Netbeans 11.3。不知何故,我所有的Web应用程序都无法启动,并且我没有进行任何更改。他们都抛出相同的异常

这里我自动生成了一个servlet,仅转发了一个JSP,但它仍然不起作用。

package servlets;

import java.io.IOException;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;


@WebServlet(name = "ExamController", urlPatterns = {"/ExamController"})
public class ExamController extends HttpServlet {

    protected void processRequest(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        response.setContentType("text/html;charset=UTF-8");
        request.getRequestDispatcher("examView.jsp").forward(request, response);
    }


    @Override
    protected void doGet(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }


    @Override
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {
        processRequest(request, response);
    }

    @Override
    public String getServletInfo() {
        return "Short description";
    }

}

[当我开始上课时,出现以下异常:Error Message

java http tomcat web servlets
1个回答
0
投票

我通过将Netbeans降级到版本11.1修复了它。

我认为Tomcat 9.0.30和版本高于11.2的Netbeans不兼容。

© www.soinside.com 2019 - 2024. All rights reserved.