servlet中使用service()方法出现错误:HTTP method POST is not supported by this URL
2013-04-08 19:21
751 查看
No.1:
错误如下图:
相关代码:
servlet中的service()方法主要用来处理客户端浏览器直接访问和以表单GET方式提交的表单以及以表单POST方式提交的表单。
但是明明用的是service()方法,为什么还会报不支持POST方式的错误呢?
No.2:
解决方案:删除步骤1中代码部分的红色代码就可以了。
No.3:
可能的错误:servlet中的servlet方法必须是protected的,如果写成public也会报同样的错误。
错误如下图:
相关代码:
@Override protected void service(HttpServletRequest request, HttpServletResponse respone) throws ServletException, IOException { super.service(request, respone); respone.setContentType("text/html;charset=utf-8"); PrintWriter out = respone.getWriter(); request.setCharacterEncoding("utf-8"); String user = request.getParameter("user"); String pwd = request.getParameter("pwd"); out.println("<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.01 Transitional//EN\">"); out.println("<HTML>"); out.println(" <HEAD><TITLE>A Servlet</TITLE></HEAD>"); out.println(" <BODY>"); out.println(" 用户名:" + user + "<br />"); out.println(" 密 码:" + pwd); out.println(" </BODY>"); out.println("</HTML>"); out.flush(); out.close(); }
servlet中的service()方法主要用来处理客户端浏览器直接访问和以表单GET方式提交的表单以及以表单POST方式提交的表单。
但是明明用的是service()方法,为什么还会报不支持POST方式的错误呢?
No.2:
解决方案:删除步骤1中代码部分的红色代码就可以了。
No.3:
可能的错误:servlet中的servlet方法必须是protected的,如果写成public也会报同样的错误。
相关文章推荐
- HTTP method POST is not supported by this URL错误的解决方案
- servlet错误:HTTP Status 405 - HTTP method GET is not supported by this URL
- 当编写Servlet时出现type Status report message HTTP method GET is not supported by this URL description The
- HTTP method POST is not supported by this URL错误的解决方案
- 关于Servlet报错:405 HTTP method GET is not supported by this URL问题解决方法
- 出现HTTP Status 405 - HTTP method GET is not supported by this URL 原因及解决方法:
- servlet错误:HTTP Status 405 - HTTP method GET is not supported by this URL
- HTTP method POST is not supported by this URL错误的解决方案
- 关于解决HTTP Status 405 - HTTP method POST is not supported by this URL方法之一
- 关于"HTTP method GET is not supported by this URL"的错误
- HTTP Status 405 - HTTP method GET(POST) is not supported by this URL
- HTTP Status 405 -- HTTP method POST is not supported by this URL
- HTTP Status 405 - HTTP method POST is not supported by this URL
- 解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
- HTTP Status 405 - HTTP method POST is not supported by this URL
- HTTP method POST is not supported by this URL
- (6) HTTP Status 405 - HTTP method POST is not supported by this URL
- HTTP method POST is not supported by this URL
- J2EE中HTTP method GET/Post is not supported by this URL
- HTTP method POST is not supported by this URL解决方案