我不知道为什么,但是当我拨打以下网址时 它给了我BAD REQUEST - INVALID URL,虽然这个URL在safari浏览器和其他浏览器上运行良好
http://www.ysl.com/wx/shop-product/women/top-handles#{"ytosQuery":"true","department":"handbags_tophandle_w","gender":"D","brand":"","macro":"","micro":"","season":"A,P,E","color":"","size":"","site":"","section":"","sortRule":"","yurirulename":"searchwithdepartment","microcolor":"","agerange":"","macroMarchio":"","page":"2","productsPerPage":"50","modelnames":"","look":"","washtype":"","fabric":"","prints":"","suggestion":"false","suggestionValue":"","material":"","occasion":"","weight":"","gal
我正在使用以下代码:
NSString *str = [NSString stringWithFormat:@"%@",[payload stringByTrimmingCharactersInSet:[NSCharacterSet whitespaceCharacterSet]]];
NSString* webStringURL = [str stringByReplacingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
webStringURL = [str stringByAddingPercentEscapesUsingEncoding:NSUTF8StringEncoding];
NSURL *payload = [NSURL URLWithString:webStringURL];
任何帮助伙伴?我做错了什么?
答案 0 :(得分:0)
不要在洞穴网址上使用stringByReplacingPercentEscapesUsingEncoding:
,而只需使用GET参数。
现在http://
也会被转义,因此成为http%3A%2F%2F
无效的网址。