Question

I am trying to setup a Client-Server communication in REST, Spring.

In the client side I have the code:

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);

In the server side I have the code (to receive the above 'variable', and get the below boolean as a return object):

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

I am not sure if the above syntax is correct. When I am running the two servers, I am getting the following error at the client side(8080):

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

Please let me know what I am missing here, and what changes I need to make in my code. Thanks in advance!

Was it helpful?

Solution

I guess you are using the wrong url to call the Web Service

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

This ends with .htm whereas your RequestMapping does not contains this request pattern

Update:

Make sure there no console errors and also, if your server application is running on 8081.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top