This article to share the content is the PHP framework call Java backend, parameter delivery is not the past problem solving, has a certain reference value, the need for friends can refer to
Public function request ($requestURL, $params = ', $method = ' GET ', $contentType = ', $user = ') {$timeout = 30; $ch = null; if (' POST ' = = = Strtoupper ($method)) {$ch = Curl_init ($requestURL); curl_setopt ($ch, Curlopt_post, 1); curl_setopt ($ch, Curlopt_fresh_connect, 1); curl_setopt ($ch, Curlopt_forbid_reuse, 1); if (is_string ($params)) {curl_setopt ($ch, Curlopt_postfields, $params); } else {curl_setopt ($ch, Curlopt_postfields, Http_build_query ($params)); }} else if (' GET ' = = = Strtoupper ($method)) {if (is_string ($params)) {$real _url = $reques Turl. (Strpos ($requestURL, '? ') = = = False? '?' : ''). $params; } else {$real _url = $requestURL. (Strpos ($requestURL, '? ') = = = False? '?' : ''). Http_build_query ($params); } $ch = Curl_init ($real _url); } else {$args = func_get_Args (); return false; } if ($contentType) {curl_setopt ($ch, Curlopt_httpheader, Array (' Content-type: '. $contentType)); } if ($user) {curl_setopt ($ch, Curlopt_userpwd, $user); } curl_setopt ($ch, Curlopt_header, 0); curl_setopt ($ch, Curlopt_returntransfer, 1); curl_setopt ($ch, Curlopt_timeout, $timeout); $ret = curl_exec ($ch); $info = Curl_getinfo ($ch); $contents = Array (' httpinfo ' = = Array (' send ' = = $params, ' url ' = = $req Uesturl, ' ret ' = $ret, ' http ' = $info,)); Curl_close ($ch); return $ret; }
System. out. println ("Content Type:" + request. getContentType ());
The Content Type passed before this method is text/html
After the value is removed, empty, passing the past default value of application/x-www-form-urlencoded
You can do it.