1. 程式人生 > >自己爬過的坑之“HTTP method POST is not supported by this URL ”

自己爬過的坑之“HTTP method POST is not supported by this URL ”

之前練習的時候,寫了個LoginServlet繼承的HttpServlet的小例子,執行的時候一直報HTTP method POST is not supported by this URL,程式碼與報錯如下,控制檯沒有報錯:

提示不支援post方法,但是程式碼裡已經設定了post方法,於是有點懵逼,之後查了一下HttpServlet原始碼裡的doPost方法

protected void doPost(HttpServletRequest req, HttpServletResponse resp)
			throws ServletException, IOException {
		String protocol = req.getProtocol();
		String msg = lStrings.getString("http.method_post_not_supported");
		if (protocol.endsWith("1.1")) {
			resp.sendError(405, msg);
		} else {
			resp.sendError(400, msg);
		}
	}

也就是說不管你的http是不是1.1的,都是用resp.sendError方法返回一個“http.method_post_not_supported”的錯誤資訊給前臺介面。也就是說問題出在super.doPost這裡,去掉就能正常運行了。一開始沒看過原始碼,直接寫的時候,eclipse自動帶出來就懶得刪,折騰了我半天,java原始碼也是,還有這種么蛾子,記下來,免得下次有爬這個坑(或許這麼寫有什麼玄機我沒參透,功力有限)。

相關推薦

自己HTTP method POST is not supported by this URL

之前練習的時候,寫了個LoginServlet繼承的HttpServlet的小例子,執行的時候一直報HTTP method POST is not supported by this URL,程式碼與報錯如下,控制檯沒有報錯: 提示不支援post方法,但是程式碼

HTTP method POST is not supported by this URL解決

ons ssa cte buffered class over err inpu public 今天寫了個非常簡單的setvlet想測試些東西,寫好了後用postman請求報錯,報錯內容如下 { "timestamp": 1504170113588, "s

HTTP Status 405 - HTTP method POST is not supported by this URL

class rec inf () 有用 serlvet 技術 body res 出現這個問題, 1、在servlet中沒有調用post()方法引起的 2、在serlvet中跳轉沒有用外跳(response.sendRedirect()) 我的是因為第一種,是沒有寫dopo

解決HTTP Status 405 - HTTP method POST is not supported by this URL

最近在寫Update資料的程式碼時,執行程式碼後總是出現了錯誤 HTTP Status 405 - HTTP method POST is not supported by this URL 在我點選修改按鈕後。並沒有跳轉到更新完成後的頁面,而是出現了405錯誤 但是查詢資料庫資料

HTTP method POST is not supported by this URL方法之一

最近在做老師佈置的javaweb作業,剛好做到了資料庫的增刪改查,犯錯總是難免的,在我寫完updateUserServlet程式碼後,執行程式碼後出現瞭如圖錯誤 在網上查了很多部落格無果後,開始自己解決問題。 一、 我的想法是在修改完成點選修改按鈕後直接返回到/sel

HTTP method POST is not supported by this URL 詳解方案

報這個錯誤提示有兩方面問題:1、在servlet中沒有呼叫post()方法引起的2、在serlvet中跳轉沒有用外跳(response.sendRedirect())我在做專案時,遇到的是1的錯誤,在servlet中沒有呼叫post().我在jsp頁面中提交一個XMLHTTP

關於"HTTP method GET is not supported by this URL"的錯誤

寫好一個Servlet後訪問時丟擲"HTTP method GET is not supported by this URL"的錯誤,先是自己找了一下原因,後又在網路查詢相關的原因後找到解決方案。 問題的原因是用Eclipse生成Servlet時,會在doGet和doPost自動新增預設

Ajax和Servlet互動,報錯HTTP Status 405 – Method Not Allowed HTTP method GET is not supported by this URL

學習慕課網的Ajax + Servlet實現搜尋框智慧提示的時候(https://www.imooc.com/learn/678) 自己打的程式碼Servlet類可以獲取到客戶端通過Ajax非同步傳送過來的資料,但是客戶端怎麼都無法獲取到服務端Servlet回傳的資料。

HTTP Status 405 – Method Not Allowed Type Status Report Message HTTP method POST is not supported b

HTTP Status 405 – Method Not Allowed Type Status Report Message HTTP method POST is not supported by this URL Description The method received

HTTP 405 method GET/POST is not supported

借鑑自:http://www.chawenti.com/articles/2852.html 問題描述: JQuery使用Ajax請求後臺Servlet出現405錯誤,不管是GET還是POST都會發生。 前臺JS/JQuery程式碼: function getServer

JVisualVMGC外掛+錯誤"not supported for this jvm"+命令jstatd

開發十年,就只剩下這套架構體系了! >>>   

Restful風格,PUT修改功能請求,表單中存在文件報錯-HTTP Status 405 - Request method 'POST' not supported

for 文件的 文件 roo spring commons 容量 put common 解決方案配置如下 <!-- 配置文件上傳解析器 --> <bean id="multipartResolver" class="org.spri

Android開發技術網路篇── http協議post請求方式

Java程式碼 程式碼如下:  private Button button1,button2,button3;  private TextView textView1;  button1.setOnClickListener(new Button.OnClickListener(){             

Java程式設計HTTPPost、Get、Put、Delete

Http:在網路中,傳送檔案、資料需要遵循的一種協議。客戶端需要和伺服器端建立聯絡,就需要使用HTTP協議,保證伺服器端可以識別客戶端的請求,並把相應的資源發給客戶端使用。例如,訪問CSDN,在不同電腦的網頁上輸入https://www.csdn.net/即可看到CSDN的網

message:Request method 'POST' not supported

message:Request method ‘POST’ not supported There was an unexpected error (type=Internal Server Error, status=500). status 405 reading UserFei

Spring Boot出現Request method 'POST' not supported,深入原始碼原因分析

工程 專案靜態資源目錄結構 testConverter.html <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <

微信小程序填page[pages/XXX/XXX] not found.May be caused by

xxx 微信小程序 for () sed cau 程序 nbsp app.js 當頁面出現 page[pages/XXX/XXX] not found.May be caused by :1. Forgot to add page route in app.json.2

INFO: Ignoring response <403 https://movie.douban.com/top250>: HTTP status code is not handled or not allowed

fin ole bug page douban erro scrapy net p s 爬取豆瓣電影top250,出現以下報錯: 2018-08-11 22:02:16 [scrapy.core.engine] INFO: Spider opened 2018-08-11

angularjs post Request header field Content-Type is not allowed by Access-Control-Allow-Headers in preflight response.

報錯 lencod pre () ons flight nbsp urlencode 請求參數 現象: 1. angular http 不配置data(請求參數)時不報錯 2. 加上請求參數後,報錯 3. 服務端response.headers().set(HttpHead

TypeError: ‘method‘ object is not subscriptable

錯誤 char script request ror error: .post apps 使用 Python Django編程時遇到如下錯誤 File "C:\Users\shisheng\PycharmProjects\cdn2018\apps\cdnproject