解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
来源:互联网 发布:网络考试系统 免费 编辑:程序博客网 时间:2024/06/05 13:29
报这个错误提示有两方面问题:
1、在servlet中没有调用post()方法引起的
2、在serlvet中跳转没有用外跳(response.sendRedirect())
我在做项目时,遇到的是1的错误,在servlet中没有调用post().我在jsp页面中提交一个XMLHTTPRequest请求到servlet时,在相应的Servlet中没用到post(),因此报这个错误。解决方案:
在Servlet中调用这个方法就行了。
对于遇到2的错误的朋友,可以采用以下解决方案:
把request.getRequestDispatcher("FindByIdServlet?id="+commentPostId).forward(request, response);
改成response.sendRedirect("FindByIdServlet?id="+commentPostId);
redirect和forward的区别:
1) redirect 方式
response.sendRedirect("test.jsp");
页面的路径是相对路径。sendRedirect可以将页面跳转到任何页面,不一定局限于本web应用中,如:
response.sendRedirect("http://www.baidu.com");
跳转后浏览器地址栏变化,会变成你跳转到的页面的地址。
这种方式要传值出去的话,只能在url中带parameter或者放在session中,无法使用request.setAttribute来传递。
2) forward方式
RequestDispatcher dispatcher = request.getRequestDispatcher("/a.jsp");
dispatcher .forward(request, response);
页面的路径是相对路径。forward方式只能跳转到本web应用中的页面上。
跳转后浏览器地址栏不会变化。
使用这种方式跳转,传值可以使用三种方法:url中带parameter,session,request.setAttribute
- 解决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 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
- (6) 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
- HTTP method POST is not supported by this URL
- HTTP method POST is not supported by this URL
- HTTP method POST is not supported by this URL解决方案
- HTTP method POST is not supported by this URL解决方案
- HTTP Status 405 - HTTP method POST/GET is not supported by this URLyi
- java servlet 错误解决 HTTP Status 405 - HTTP method GET is not supported by this URL type
- 访问arcgisserver报:HTTP Status 405 - HTTP method GET is not supported by this URL
- 黑马程序员----7.08
- 大道于足下
- winsock编程宝典之收送消息
- QT UI文件解析
- 常见的防盗链方法总结及分析
- 解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
- get请求和post的请求的乱码解决
- 获取treeview中当前鼠标所指的节点treenode
- 进程
- org.hibernate.hql.ast.QuerySyntaxException:is not mapped
- C++的纯虚函数和抽象类
- MongoDB常用的操作命令
- C语言常见误区
- SQL 2005 -窗口函数(OVER)