2013-08-06 34 views
0

我正在嘗試在REST,Spring中設置客戶端 - 服務器通信。REST,Spring(RestTemplate)中的客戶端 - 服務器通信:獲取404錯誤

在客戶端側我的代碼:

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 

請讓我知道我在這裏失蹤,和什麼樣的變化,我需要在我的代碼進行。 在此先感謝!

回答

0

我猜你使用了錯誤的URL來調用Web服務

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

這與熱媒結束,而你的RequestMapping不包含這個請求的樣式

更新:

確保那裏沒有控制檯錯誤,並且如果您的服務器應用程序正在運行8081.

+0

在我的web.xml中我有: SpringMVCerchant * .htm kajarigd

+0

它仍然無法正常工作。你能幫忙嗎? – kajarigd

+0

但你是否更新了控制器上的請求映射,從movieTheater到movieTheater.htm –