The following records the data request problem:
1. Do not know that we have encountered the wood, when the URL of the data request with Chinese characters, the request data will be reported 404 error, that is, the parameters or interface URL Error < Although 404,500 and other errors are generally a server problem, but ... What I want to say is that most of us ask for parameters or URL problems yo!!! >
At this time you will have to check your request parameters and address is not wrong yo!
2. When the data request with the Chinese characters, it is generally to be converted to UTF8 encoding, in order to make data requests.
NSString *searchstr1 = [Searchstr stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];
Some data may be transferred once enough, some .... But not necessarily.
Please look down at yo ...
3. Android seems to be a transcoding just fine ... It's just ... iOS doesn't seem to work ... Hehe!!!
Anyway, I tried a lot of times do not, has been reported 404 errors .... After many attempts, it is finally found how to solve the problem ...
The solution is: two times UTF8 transcoding
Look at the following my Code implementation: Enter Chinese to search for request data.
1 #pragmaMark-uisearchdelegate2 3- (void) searchbarsearchbuttonclicked: (Uisearchbar *) searchbar{4 5Self.searchBar.showsCancelButton =NO;6 [Searchbar Resignfirstresponder];7 //Request search Data8NSString *searchstr =[Searchbar.text stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];9NSString *SEARCHSTR1 =[Searchstr stringbyaddingpercentescapesusingencoding:nsutf8stringencoding];TenSelf.searchtext =searchStr1; One A //Note that you need to transcode two times to succeed!!! - [self requeststudentlist:searchstr1]; -}
iOS server data Request "Chinese character coding" issue