admin管理员组

文章数量:1565349

import org.springframework.http.HttpEntity;
import org.springframework.http.HttpHeaders;
import org.springframework.http.MediaType;
import org.springframework.util.LinkedMultiValueMap;
import org.springframework.util.MultiValueMap;
import org.springframework.web.client.RestTemplate;


public static void main(String args[]){
        String url="http://127.0.0.1/api/getToken";
        HttpHeaders header = new HttpHeaders();
        headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);
        RestTemplate restTemplate=new RestTemplate();
        MultiValueMap<String, String> forms= new LinkedMultiValueMap<String, String>();
        forms.put("username", Collections.singletonList("username"));
        forms.put("password", Collections.singletonList("password"));
        HttpEntity<MultiValueMap<String, String>> httpEntity = new HttpEntity<MultiValueMap<String, String>>(forms, header);
        String result = restTemplate.postForObject(url, httpEntity, String.class);
        }

本文标签: 后端typeContentJavaForm