我想在Web應用程序(REST,Spring,JPA Hibernate)中返回一個布爾值作爲HTTP響應。這裏的代碼:需要返回布爾@ResponseBody。現在得到HTTP 406錯誤
@ResponseBody
@RequestMapping(value="/movieTheater", method=RequestMethod.GET)
public boolean getCustomerInput(Map<String, Double> input) {
return transactionService.addTransaction(input);
}
現在,我想這不是讓我返回一個布爾值,但期待別的。當我試圖在瀏覽器中訪問以下內容:
http://localhost:8081/SpringMVCMerchant/movieTheater.htm
我收到以下錯誤:
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.
能否請你告訴我的方式發送布爾作爲響應?如果不是,我還能做什麼? 在此先感謝!
非常感謝您的回覆!我嘗試了上述步驟,但我仍然收到相同的406錯誤。我所做的是,我將step1和step2添加到客戶端代碼和服務器代碼中。所以,現在在客戶端我有代碼:ResponseText rresult = restTemplate.getForObject(「http:// localhost:8081/SpringMVCMerchant/movieTheater.htm」,ResponseText.class,variable);但是我得到了406錯誤,因此,rresult.getMessage()會變爲null。您能否告訴我在這裏是否缺少任何東西,或者我誤解了您的步驟?謝謝! – kajarigd