http请求记录post请求设置参数格式及传入参数


            org.apache.httpcomponents
            httpclient
            4.5.5
        

http请求设定参数格式,传入必须参数 

//设置Http Header
        HttpHeaders headers = new HttpHeaders();
        //设置请求媒体数据类型
        headers.setContentType(MediaType.valueOf(MediaType.APPLICATION_FORM_URLENCODED_VALUE));
        //设置返回媒体数据类型
        headers.add("Accept", MediaType.APPLICATION_JSON.toString());

            MultiValueMap paramMap = new LinkedMultiValueMap<>();

            paramMap.add("corporateid",USERID);
            paramMap.add("userid",USERNAME);
            paramMap.add("password",PASSWORD);
            paramMap.add("mobile",tblMt.getUSERNUMBER());
            paramMap.add("content",tblMt.getCONTENT());

            HttpEntity> httpEntity = new HttpEntity<>(paramMap,headers);
            String gwreTurnValue  = this.restTemplate.postForObject(requestUrl, httpEntity, String.class);

 

你可能感兴趣的:(spring,boot,httpclient)