gamesetting.jsp上にあるfullCalendarにJSON配列を送信しようとしています。 json配列オブジェクトはコンソール経由でテストされていて、 これは正解を示しています。私は$( "#calendar")を試しました。fullCalendar( 'addEventSource'、source)、クロムは406エラーを返し、応答はThe resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.
スプリング@ResponseBodyのFullcalendarがJson Arrayを406エラーで返します:受け入れられないヘッダー
jsonArray: [{"game_name":"A vs B","game_time":"2015-05-20 00:00:00.0","game_no":1}]
と、これは私のJavaScriptコード
$(document).ready(function() {
$('#calendar').fullCalendar({
customButtons: {
myCustomButton: {
text: 'custom!',
click: function getGames(e){
var games;
var url='selectAllGames.controller';
if (getGames){
$.getJSON(url,null,
function(){$("#calendar").fullCalendar('addEventSource',url)})
;}
console.log(e);
}
}
},
であるに示す
@RequestMapping (method=RequestMethod.GET ,produces={"application/json; charset=UTF-8"})
public @ResponseBody JSONObject returnGames(GameVO gameVo,HttpServletResponse response) throws IOException{
GameService gService= new GameService(gameDao);
List<GameVO> games= gService.select(gameVo);
JSONArray jsonArray = new JSONArray();
JSONObject jsonObj =null;
for(GameVO game:games){
jsonObj = new JSONObject();
jsonObj.put("game_no", game.getGame_sd());
jsonObj.put("game_name", game.getGame_name());
jsonObj.put("game_time", game.getGame_time());
jsonArray.put(jsonObj);
}
System.out.println("jsonArray: "+jsonArray);
response.setHeader("Accept", "application/json");
return jsonObj;
}
...
この行を削除するとどうなるでしょうか?response.setHeader(" Accept "、" application/json ");' –
@Sagar Rohankar - レスポンスヘッダーには受け入れられないプロパティがあり、同じ記述で406エラーが返されます。 –