@PostMapping(value = "test2")
@ResponseBody
public ResponseBox<String> test2(int id, String username, String password) {
    System.out.println("post test2 run id=" + id + " username=" + username + " password=" + password);
    ResponseBox box = new ResponseBox();
    box.setResponseCode(200);
    box.setData("test2 value");
    box.setMessage("操作成功");
    return box;
}

public class Test2 { public static void main(String[] args) throws JsonProcessingException { int id = 100; String username = "~!@#$%^&()_+-={}[]|;:'<>?,./"; String password = "~!@#$%^&()_+-={}[]|;:'<>?,./";

    HttpHeaders headers = new HttpHeaders();
    headers.setContentType(MediaType.APPLICATION_FORM_URLENCODED);


    //??????what do ??  top 3 param use post type submit springMVC controller
    //note:no create entity class way. like key=value

    HttpEntity<String> entity = new HttpEntity( ???,headers);

    RestTemplate template = new RestTemplate();
    ResponseEntity<ResponseBox<String>> responseEntity = template.exchange(URI.create("http://localhost:8080/post/test2"), HttpMethod.POST, entity, new ParameterizedTypeReference<ResponseBox<String>>() {
    });
    ResponseBox<String> box = responseEntity.getBody();
    System.out.println(box.getResponseCode() + " " + box.getData() + " " + box.getMessage());
}

}


internet not find answer , so go to the issues ..thank you !!!

Comment From: bclozel

Thanks for getting in touch, but it feels like this is a question that would be better suited to Stack Overflow. As mentioned in the guidelines for contributing, we prefer to use the issue tracker only for bugs and enhancements. Feel free to update this issue with a link to the re-posted question (so that other people can find it) or add some more details if you feel this is a genuine bug.

You'll find also more information in the reference docs or by looking at getting started guides. In this case you should use a MultiValueMap as a request body with your client.