问题
I have a Webview In that I am loading web with Query string perimeters like
String url = map.get("utype") + map.get("sid") + "/login/login.php?"+"&"+"strid" + "=" + map.get("strid")+"&"+"appmod" + "=" + map.get("appmod")+"&" +"ttype" + "=" + map.get("ttype")+"&" +"payp" + "=" + map.get("payp");
I am loading that Query string in webview
webView.loadUrl(url);
So Now Insted of using Query string I want to POST Parameters to x-www-form-urlencoded
These are my Parameters
strid = map.get("strid");
appmod = map.get("appmod");
ttype = map.get("ttype");
payp = map.get("payp");
I followed this but its not Working
can any one help me on this..
I want to POST data to x-www-form-urlencoded
in Web-view
After posting I it will load my Web-server(website).
Update
I have Given these values for post
String postData="strid="+URLEncoder.encode(map.get("strid"), "UTF-8")+
"&appmod="+URLEncoder.encode(map.get("appmod"), "UTF-8")+
"&ttype="+URLEncoder.encode(map.get("ttype"), "UTF-8")+
"&payp="+URLEncoder.encode(map.get("payp"), "UTF-8");
Now after Adding The Details I have given this to at URL
webView.postUrl(url,postData.getBytes());
But still Its not working
can anyone suggest me whats wrong
回答1:
You need to call webView.postUrl(url, encodedData);
Values must be encoded with URLEncoder.encode(postData, "UTF-8") or "BASE64" depends on backend.
If its not working make sure you have url in correct format. You can also share it to here without exposing your values if you are not sure.
来源:https://stackoverflow.com/questions/53810759/andorid-webview-how-to-post-data-to-application-x-www-form-urlencoded