ResponseEntity を使用してテストする次の簡単な Spring MVC テスト メソッドがあります。
@RequestMapping(value = "/", method = RequestMethod.GET, produces= MediaType.APPLICATION_JSON_VALUE)
public ResponseEntity<Map<String, String>> home(Locale locale, Model model) {
Map<String,String> returnMap = new HashMap<String,String>(2);
returnMap.put("lang1", "Java");
returnMap.put("lang2", "C++");
ResponseEntity<Map<String, String>> respEntity = new ResponseEntity<Map<String,String>>(returnMap, HttpStatus.OK);
return respEntity;
}
ResponseEntity が作成され、Eclipse デバッガーで、ResponseEntity オブジェクトの本文、ヘッダー、およびステータス コードがすべて正しいことを確認できますが、ページで次のエラーが発生します。
The resource identified by this request is only capable of generating
responses with characteristics not acceptable according to the request
"accept" headers ().
誰かが私が間違っていることを教えてくれたら本当にありがたいです。