REST,Spring(RestTemplate)中的客户端 - 服务器通信:获得404错误

时间:2013-08-06 18:30:20

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

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

在客户端,我有代码:

Map<String, Double> variable = new HashMap<String, Double>(1);
variable.put(newTicket.getMovieName(),newTicket.getTicketPrice());
try{    
     Boolean rresult = restTemplate.getForObject("http://localhost:8081/SpringMVCMerchant/movieTheater.htm", Boolean.class, variable);

在服务器端,我有代码(接收上面的'变量',并获得以下布尔值作为返回对象):

@ResponseBody
@RequestMapping(value="/movieTheater/", method=RequestMethod.GET)
public boolean getCustomerInput(Map<String, Double> input) {
    return transactionService.addTransaction(input);
}

我不确定上述语法是否正确。当我运行这两台服务器时,我在客户端收到以下错误(8080):

GET request for "http://localhost:8081/SpringMVCMerchant/movieTheater.htm" resulted in 404 (Not Found); invoking error handler

请告诉我这里缺少的内容,以及我需要在代码中进行哪些更改。 提前谢谢!

1 个答案:

答案 0 :(得分:0)

我猜您使用了错误的网址来调用Web服务

http://localhost:8081/SpringMVCMerchant/movieTheater.htm

以.htm结尾,而您的RequestMapping不包含此请求模式

更新

确保没有控制台错误,以及服务器应用程序是否在8081上运行。