本文介绍了没有加载的事件:jquery完整日历Java集成的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我尝试通过控制器将事件加载到完整日历中
这是我在jsp上的脚本:
$(document).ready(function(){
var calendar = $('#calendar')。fullCalendar ({
editable:true,
eventSources:[{
//您的事件源
url:'calendarDetails',
类型:'GET',
数据:{
start:'start',
id:'id',
title:'title,'
},
error:function(){
alert('提取事件时发生错误!');
},
颜色:'yellow',
textColor:'black'
}])
};)
};
和我的控制器里面:
<$ p $
public @ResponseBody void showCalendarDetails(HttpServletResponse响应){
Map< String,$ value =/ calendarDetails,method = RequestMethod.GET)对象> 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/);
//转换为JSON字符串。
String json = new Gson()。toJson(map);
logger.info(json);
//写入JSON字符串。
response.setContentType(application / json);
response.setCharacterEncoding(UTF-8);
尝试{
response.getWriter()。write(json);
} catch(IOException e){
// TODO自动生成的catch块
e.printStackTrace();
}
请求和响应显示正常状态,
我可以看到响应在firebug中作为json发回,如{id:111,title:event1,start:2011-07-28,url:http:// yahoo .com /}
然而,完整的日历不会显示加载的事件。我错过了什么?
在此先感谢您的帮助。 p>你试过从 title:'title,'
?>删除逗号吗?
I am trying to load events to full calendar via a controller
Here is my script on the 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'
}])
};)
};
and inside my controller:
@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();
}
The request and response are showing an ok status andI can see the response being sent back as a json in the firebug as {"id":111,"title":"event1","start":"2011-07-28","url":"http://yahoo.com/"}
However the full calendar will not show the event loaded. Am I missing something?
Thanks in advance for your help.
解决方案
Have you tried to remove the comma from title: 'title,'
?
这篇关于没有加载的事件:jquery完整日历Java集成的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!