you can do it like this:
Code:
public void post() {
MultiValueMap<String, String> map = new LinkedMultiValueMap<String, String>();
map.add("name", "xx");
map.add("password", "xx");
String result = rest.postForObject("http://localhost:8080/soa-server/user/", map, String.class);
System.out.println(result);
}
and before you use resttemplate you must init it :
Code:
RestTemplate rest = new RestTemplate();
HttpMessageConverter formHttpMessageConverter = new FormHttpMessageConverter();
HttpMessageConverter stringHttpMessageConverternew = new StringHttpMessageConverter();
rest.setMessageConverters(new HttpMessageConverter[]{formHttpMessageConverter, stringHttpMessageConverternew});
my english is not very good , sorry. I do not know can you understand me
Last edited by oakeye; Nov 24th, 2009, 06:40 PM.
source - http://forum.spring.io/forum/spring-projects/web/70845-sending-post-parameters-with-resttemplate-requests