一、問題描述
在postman接口調試中響應的資料都是正常的,使用httpclient當傳送錯誤參數時響應為null,傳送正常資料時卻可以接收到資料
二、解決問題
問題的原因也是因為懶惰,每次使用工具類時直接在網上摘抄,沒有好好關注過工具類的具體實作。下邊是在網上随便搜尋的httpclient工具類。

以下是httpstatus類的狀态詳解。
- //Informational 1xx 資訊
- '100' : 'Continue', //繼續
- '101' : 'Switching Protocols', //交換協定
- //Successful 2xx 成功
- '200' : 'OK', //OK
- '201' : 'Created', //建立
- '202' : 'Accepted', //已接受
- '203' : 'Non-Authoritative Information', //非權威資訊
- '204' : 'No Content', //沒有内容
- '205' : 'Reset Content', //重置内容
- '206' : 'Partial Content', //部分内容
- //Redirection 3xx 重定向
- '300' : 'Multiple Choices', //多種選擇
- '301' : 'Moved Permanently', //永久移動
- '302' : 'Found', //找到
- '303' : 'See Other', //參見其他
- '304' : 'Not Modified', //未修改
- '305' : 'Use Proxy', //使用代理
- '306' : 'Unused', //未使用
- '307' : 'Temporary Redirect', //暫時重定向
- //Client Error 4xx 用戶端錯誤
- '400' : 'Bad Request', //錯誤的請求
- '401' : 'Unauthorized', //未經授權
- '402' : 'Payment Required', //付費請求
- '403' : 'Forbidden', //禁止
- '404' : 'Not Found', //沒有找到
- '405' : 'Method Not Allowed', //方法不允許
- '406' : 'Not Acceptable', //不可接受
- '407' : 'Proxy Authentication Required', //需要代理身份驗證
- '408' : 'Request Timeout', //請求逾時
- '409' : 'Conflict', //指令沖突
- '410' : 'Gone', //文檔永久地離開了指定的位置
- '411' : 'Length Required', //需要Content-Length頭請求
- '412' : 'Precondition Failed', //前提條件失敗
- '413' : 'Request Entity Too Large', //請求實體太大
- '414' : 'Request-URI Too Long', //請求URI太長
- '415' : 'Unsupported Media Type', //不支援的媒體類型
- '416' : 'Requested Range Not Satisfiable', //請求的範圍不可滿足
- '417' : 'Expectation Failed', //期望失敗
- //Server Error 5xx 伺服器錯誤
- '500' : 'Internal Server Error', //内部伺服器錯誤
- '501' : 'Not Implemented', //未實作
- '502' : 'Bad Gateway', //錯誤的網關
- '503' : 'Service Unavailable', //服務不可用
- '504' : 'Gateway Timeout', //網關逾時
- '505' : 'HTTP Version Not Supported' //HTTP版本不支援