Spring MVC - 如何在请求映射中传递HashMap

时间:2013-04-10 13:24:59

标签: spring-mvc

我正在使用带有RESTFullWebService的Spring MVC。

来自我的客户端程序的代码片段

RestTemplate restTemplate = new RestTemplate();

String startProcessURL = "http://"+hostAddress+":"+portNumber+"/jBPMSpring/process/startProcess/"+processId

上面的代码工作正常,当我使用RequestMapping.GET方法时。

从我的客户端程序中,我需要在请求映射(POST)中传递HashMap。

我需要做些什么更改来传递HashMap。

1 个答案:

答案 0 :(得分:0)

有两个选项,postForLocation或postForObject

在初始化之后,你可以将你的hashmap包装在一个类中:

String result = rest.postForObject("http://whatever.com/whenever/", yourClass, String.class,);