FullCalendar从后台获取查询后的JSON数据

来源:互联网 发布:淘宝发货地什么意思 编辑:程序博客网 时间:2024/06/04 17:42

最近项目中遇见了使用FullCalendar开发日程的东西,在网上找了一些资料熟悉了一下,设置参数配置使FullCalendar能够正确显示,然后就是事件列表了,事件events可以是一个数组也可以用一个URL作为参数,我这里采用的是URL,参考FullCalendar的documentation,在请求后台数据时,它会自动在url上面加上两个参数,开始时间和结束时间,


The GET parameter names will be determined by the startParam and endParam options. ("start" and "end" by default).

默认是start和end,你也可以通过startParam和endParam改成自己想要的名称。


后台接受参数使用request.getParameter("start");获取这个时间值,这个时间是long类型的,“The value of the parameters will always be UNIX timestamps (seconds since 1970).”,所以我们后台获取之后需要处理一下,然后才能转换成Date对象

long start = Long.parseLong(request.getParameter("start").toString());

Date startDate = new Date(start * 1000);

此时,就可以拿着这个参数去查询events列表,然后response输出JSONArray对象即可.

 

原创粉丝点击