I am trying to return a boolean as a HTTP Response in a web application (REST, Spring, JPA Hibernate). Here's the code:
@ResponseBody
@RequestMapping(value="/movieTheater", method=RequestMethod.GET)
public boolean getCustomerInput(Map<String, Double> input) {
return transactionService.addTransaction(input);
}
Now, I guess this is not allowing me to return a boolean, but expecting something else. When I am trying to access in the browser the following:
http://localhost:8081/SpringMVCMerchant/movieTheater.htm
I am getting the following error:
HTTP Status 406 -
type Status report
message
description The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
Can you please tell me a way to send boolean as a response? If not, what else can I do? Thanks in advance!
Update your version of spring to 3.1.3.release or higer.Then the @Responsebody will convert the boolean to JSON correctly.
step 1: create an Enum
step 2: create a class for returning the response details
step 3: modify the code as following
now you can get output JSON like this
Seems issue in produce JSON data, add the property produces like this