1.errorcode為-1011
在程序執(zhí)行中發(fā)現(xiàn)錯誤镇饺,請求時請求數(shù)據(jù)并沒有被服務(wù)器接收查看error信息
Error Domain=com.alamofire.error.serialization.response Code=-1011 "Request failed: internal server error (500)" UserInfo={com.alamofire.serialization.response.error.response=<NSHTTPURLResponse: 0x13e764750> { URL: http://192.168.**.**:8080/** } { status code: 500, headers {
Connection = close;
"Content-Length" = 93;
"Content-Type" = "application/json;charset=UTF-8";
Date = "Thu, 21 Jul 2016 05:09:59 GMT";
Server = "Apache-Coyote/1.1";
} }, NSErrorFailingURLKey=http://192.168.**.**:8080/**, com.alamofire.serialization.response.error.data=
<0a7b0a20 20226572 72223a20 7b0a2020 20202263 6f646522 3a203530 302c0a20 20202022 6d736722 3a2022e6 97a0e6b3 95e5a484 e79086e6 82a8e79a 84e8afb7 e6b18222 2c0a2020 20202265 76656e74 6964223a 2022220a 20207d0a 7d>,
NSLocalizedDescription=Request failed: internal server error (500)}
出現(xiàn)這個問題尝偎,從錯誤信息中找到了答案Request failed: internal server error (500),這里所指的是服務(wù)端內(nèi)部錯誤,在調(diào)試中發(fā)現(xiàn)服務(wù)器并沒有接收到相關(guān)數(shù)據(jù)。
去官方文檔上查看錯誤原因
NSURLErrorBadServerResponseReturned when the URL Loading system receives bad data from the server.This is equivalent to the “500 Server Error” message sent by HTTP servers.Available in OS X v10.2 and later.
服務(wù)器接收到錯誤數(shù)據(jù)呢诬,因此懷疑是否在參數(shù)傳遞中發(fā)生錯誤。但是錯誤的情況是有時發(fā)生胖缤,大多數(shù)情況下還是正常尚镰,因此排除在客戶端方向的錯誤,在服務(wù)器端尋找錯誤哪廓。
向服務(wù)端請求查看錯誤狗唉,服務(wù)端查看錯的方法:1.查看tomcat控制臺輸出日志,從這里可以查看出tomcat這個應(yīng)用是不是向服務(wù)端發(fā)送請求了涡真,2.查看tomcat的log日志分俯,這里可以查看出代碼到底錯在哪里,什么原因?qū)е碌奈疫@里出現(xiàn)的問題是數(shù)據(jù)庫中哆料,主鍵沖突的原因?qū)е聢箦e缸剪,解決方案我就不詳細(xì)說明了。
文章優(yōu)先發(fā)表于:http://keyliu.com
轉(zhuǎn)載請注明出處东亦。