javac 无法编译 带@WebServlet 的 Servlet
importjava.io.*;importjavax.servlet.*;importjavax.servlet.http.*;@WebServlet("/hello....
import java.io.*;
import javax.servlet.*;
import javax.servlet.http.*;
@WebServlet("/hello.view")
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello</H1>\n" +
"</BODY></HTML>");
}
}
javac HelloServlet.java
HelloServlet.java:12 错误:找不到符号
@WebServlet("/hello.view")
^
符号:类 WebServlet
1个错误
把@WebServlet去除就ok 展开
import javax.servlet.*;
import javax.servlet.http.*;
@WebServlet("/hello.view")
public class HelloServlet extends HttpServlet {
public void doGet(HttpServletRequest request,
HttpServletResponse response)
throws ServletException, IOException {
response.setContentType("text/html");
PrintWriter out = response.getWriter();
String docType =
"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0 " +
"Transitional//EN\">\n";
out.println(docType +
"<HTML>\n" +
"<HEAD><TITLE>Hello</TITLE></HEAD>\n" +
"<BODY BGCOLOR=\"#FDF5E6\">\n" +
"<H1>Hello</H1>\n" +
"</BODY></HTML>");
}
}
javac HelloServlet.java
HelloServlet.java:12 错误:找不到符号
@WebServlet("/hello.view")
^
符号:类 WebServlet
1个错误
把@WebServlet去除就ok 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询