求助:servlet运行时出现的问题 HTTP method GET is not supported by this URL
各位兄弟姐妹,小弟在调试JSP的时候遇到一个问题:
servlet运行时出现的问题 HTTP method GET is not supported by this URL
昨晚调了一晚都搞不定,代码如下:
package ch07;
import javax.servlet.*;
import javax.servlet.http.*;
import java.io.*;
public class SampleServlet1 extends HttpServlet {
public void doGet(HttpServlet request,HttpServletResponse response)
throws ServletException,IOException{
response.setContentType( "text/html;charset=GB2312 ");
PrintWriter out = response.getWriter();
out.println( " <html> ");
out.println( " <head> <title> Servlet </title> </head> ");
out.println( " <body> ");
out.println( "大家好 ");
out.println( " </body> ");
out.println( " </html> ");
out.close();
}
}
[解决办法]
doGet()改成service()
[解决办法]
public void doGet(HttpServletRequest request,HttpServletResponse response)
throws ServletException,IOException{
你参数定义错误了,结果你的Servlet并没有覆盖父类的方法