写servlet时出现问题HTTP method POST is not supported by this URL如下图所示:
我的出错原因:
public void doPost( HttpServletResponse response,HttpServletRequest request) throws IOException, ServletException { Enumeration e = request.getParameterNames(); PrintWriter out = response.getWriter(); while (e.hasMoreElements()) { String name = (String) e.nextElement(); String value = request.getParameter(name); out.println("<html><body>"+ name + "=" + value + "<hr /><body/><html/>"); }
代码中HttpServletResponse response,HttpServletRequest request
二者位置写反了
解决办法:
改为public void doPost(HttpServletRequest request,HttpServletResponse response) throws IOException, ServletException
即可。
HTTP method POST is not supported by this URL
最新推荐文章于 2024-07-29 14:22:26 发布