我正在尝试通过控制器将事件加载到完整日历
这是我在jsp上的脚本:
$(document).ready(function () {
var calendar = $('#calendar').fullCalendar({
editable: true,
eventSources: [{
// your event source
url: 'calendarDetails',
type: 'GET',
data: {
start: 'start',
id: 'id',
title: 'title,'
},
error: function () {
alert('there was an error while fetching events!');
},
color: 'yellow',
textColor: 'black'
}])
};)
};
@RequestMapping(value="/calendarDetails", method=RequestMethod.GET)
public @ResponseBody void showCalendarDetails(HttpServletResponse response){
Map<String, Object> map = new HashMap<String, Object>();
map.put("id", 111);
map.put("title", "event1");
map.put("start", "2011-07-28");
map.put("url", "http://yahoo.com/");
// Convert to JSON string.
String json = new Gson().toJson(map);
logger.info(json);
// Write JSON string.
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
try {
response.getWriter().write(json);
} catch (IOException e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
请求和响应显示正常状态 我可以看到响应作为json在firebug中作为{“id”:111,“title”:“event1”,“start”:“2011-07-28”,“url”:“http:/ /yahoo.com /“}
但是,完整日历不会显示已加载的事件。我错过了什么吗?
提前感谢您的帮助。
答案 0 :(得分:0)
您是否尝试从title: 'title,'
删除逗号?