解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
来源:互联网 发布:校园女生暴力数据 编辑:程序博客网 时间:2024/06/05 12:40
报这个错误提示有两方面问题:
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
- ADF: 如何在首次进入页面时避免table自动执行view object的查询
- 管理及IO重定向
- sonar 搭建
- Oracle 取随机数
- ios学习笔记---simpleping
- 解决HTTP Status 405 - HTTP method POST is not supported by this URL 详解方案
- Python 机器学习工具库
- 字典树 ,map 容器 hdu 1251
- Linux下修改某个用户使用时的编码
- StackWalk64
- Struts2中Session的使用
- 盘点2013:21款最优秀的开源数据库
- javascript Ajax 学习总结
- 实现动态SQL的select into