REST中的客户端服务器通信:使用RestTemplate:无法将数据发送到服务器端

时间:2013-08-07 09:20:33

标签: java rest spring-mvc client-server resttemplate

我正在尝试在REST,Spring中设置客户端 - 服务器通信。

在客户端,我有代码:

rresult = restTemplate.getForObject("http://localhost:8081/SpringMVCMerchant/movieTheater.htm", ResponseText.class, variable);

上面的变量是HashMap。我希望将此值变量传输到服务器端代码。我的服务器端代码是:

@ResponseBody
@RequestMapping(value="/movieTheater", method=RequestMethod.GET)
public ResponseText getCustomerInput(Map<String, Double> input) {
    Transaction transaction = new Transaction();
    ResponseText result = new ResponseText();
    if(transactionService.addTransaction(input))
        result.setMessage(ResponseStatus.SUCCESS.getStatus());
    else
        result.setMessage(ResponseStatus.FAILED.getStatus());
    return result;
}

在这方面,我期待Map输入将接收Map变量的值。但是,这种情况并没有发生。我不想将值作为url参数发送。你能告诉我怎么解决这个问题吗?

提前致谢!

1 个答案:

答案 0 :(得分:0)

您可以执行HTTP POST请求,而不是HTTP Get请求。

请参阅:https://stackoverflow.com/a/15944890/2179109