这是我的代码
public class hi extends GenericServlet{
public void init(ServletConfig parm1){
}
@Override
public void service(ServletRequest req,ServletRequest res){
PrintWriter pw = res.getWriter();
pw.println("hi");
}
}
当我尝试编译时:
hi.java:16: error: hi is not abstract and does not override abstract method service(ServletRequest,ServletResponse) in GenericServlet
public class hi extends GenericServlet{
^
hi.java:21: error: method does not override or implement a method from a supertype
@Override
^
hi.java:23: error: cannot find symbol
PrintWriter pw = res.getWriter();
^
symbol: method getWriter()
location: variable res of type ServletRequest
3 errors
我想我已经覆盖了GenericServlet的service
方法,但编译器确实得到了它,让我感到很困惑......
答案 0 :(得分:0)
服务方法的第二个参数应该是ServletResponse