我正在讨论大学的一章,我正在研究 servlet。这本书要求我复制一段代码并在cmd中运行。它不会在 cmd 中运行,并且这一章模糊地解释了我如何安装 Java EE。这是代码和错误:
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
public class NameServlet extends HttpServlet {
public static void main(String[] args) {
}
public void doGet(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html>");
out.println("<body style=’background-color: lightyellow’>");
String name = "Wow, this servlet works great!!";
out.println("Name: " + name);
out.println("</body>");
out.println("</html>");
out.close();
}
public void doPost(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException {
doGet(request, response);
}
}
错误: