标签:http io os ar java sp on 问题 代码
写好一个Servlet后访问时抛出"HTTP method GET is not supported by this URL"的错误,先是自己找了一下原因,后又在网络查找相关的原因后找到解决方案。
问题的原因是用Eclipse生成Servlet时,会在doGet和doPost自动添加默认调用父类的构造方法,如下红色标识代码:
/** * @see HttpServlet#doGet(HttpServletRequest request, HttpServletResponse response) */ protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub super.doGet(request, response); } /** * @see HttpServlet#doPost(HttpServletRequest request, HttpServletResponse response) */ protected void doPost(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { // TODO Auto-generated method stub super.doPost(request, response); }
Servlet HTTP method GET is not supported HTTP 405
标签:http io os ar java sp on 问题 代码
原文地址:http://my.oschina.net/alexgaoyh/blog/333004