当前位置: 代码迷 >> Java Web开发 >> servlet运行时出现的有关问题 HTTP method GET is not supported by this URL
  详细解决方案

servlet运行时出现的有关问题 HTTP method GET is not supported by this URL

热度:615   发布时间:2016-04-17 15:33:36.0
求助: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并没有覆盖父类的方法
  相关解决方案