gpt4 book ai didi

java servlet编译错误

转载 作者:行者123 更新时间:2023-11-28 22:42:29 29 4
gpt4 key购买 nike

<分区>

1.i 添加路径 C:\Program Files (x86)\Java\jdk1.6.0_01\bin for java 和 C:\TOMCAT\apache-tomcat-7.0.55\lib for tomcat。

2.我启动了C:\TOMCAT\apache-tomcat-7.0.55\bin下的startup.bat,运行正常。

3.显示在8084端口(localhost:8084/)

4.i 在目录E 中创建了一个MyServlet.java 文件。

5.我想通过命令行编译它(javac MyServlet.java)bt错误来了。

我试了又试 bt.. :( ..plz 帮我解决它。

MyServlet.java代码:

import javax.servlet.*; 
import javax.servlet.http.*;
import java.io.*;
import java.io.IOException;
import java.io.PrintWriter;

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

public class MyServlet extends HttpServlet
{
public void doGet(HttpServletRequest request,HttpServletResposne response)
throws ServletException
{
response.setContentType("text/html");
PrintWriter out = response.getWriter();
out.println("<html><body>");
out.println("<h1>Hello Readers</h1>");
out.println("</body></html>");
}
}

和命令错误:

E:\>javac MyServlet.java
MyServlet.java:1: package javax.servlet does not exist
import javax.servlet.*;
^
MyServlet.java:2: package javax.servlet.http does not exist
import javax.servlet.http.*;
^
MyServlet.java:7: package javax.servlet does not exist
import javax.servlet.ServletException;
^
MyServlet.java:8: package javax.servlet.http does not exist
import javax.servlet.http.HttpServlet;
^
MyServlet.java:9: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletRequest;
^
MyServlet.java:10: package javax.servlet.http does not exist
import javax.servlet.http.HttpServletResponse;
^
MyServlet.java:12: cannot find symbol
symbol: class HttpServlet
public class MyServlet extends HttpServlet
^
MyServlet.java:14: cannot find symbol
symbol : class HttpServletRequest
location: class MyServlet
public void doGet(HttpServletRequest request,HttpServletResposne response)
^
MyServlet.java:14: cannot find symbol
symbol : class HttpServletResposne
location: class MyServlet
public void doGet(HttpServletRequest request,HttpServletResposne response)
^
MyServlet.java:15: cannot find symbol
symbol : class ServletException
location: class MyServlet
throws ServletException
^
10 errors

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com