【问题标题】:Unable to display calendar events in fullcalendar dashboard using jquery and java无法使用 jquery 和 java 在 fullcalendar 仪表板中显示日历事件
【发布时间】:2015-11-21 01:42:18
【问题描述】:

我无法在全日历仪表板上显示事件(存在于我的数据库中)。我创建了一个 JSON 文件,其中包含我在运行时获取的 JSON 事件数组。我将 jquery 中事件的 url 作为

$('#calendar').fullCalendar({
    header: {
        left: 'prev,next today',
        center: 'title',
        right: 'month,agendaWeek,agendaDay'
    },

    events: '${pageContext.request.contextPath}/calendarFetch',

我的动态生成的 json 文件具有这种格式的输出

{
    "events": [
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        },
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        },
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        },
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        },
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        },
        {
            "start": "2015-11-09 01:30:00",
            "end": "2015-11-09 02:30:00",
            "title": "Meeting with Professor"
        }
    ]
}

【问题讨论】:

    标签: java jquery json fullcalendar


    【解决方案1】:

    事件提要输出应该为一组对象发送 json,如下所示

    [
            {
                "start": "2015-11-09 01:30:00",
                "end": "2015-11-09 02:30:00",
                "title": "Meeting with Professor"
            },
            {
                "start": "2015-11-09 01:30:00",
                "end": "2015-11-09 02:30:00",
                "title": "Meeting with Professor"
            }
    ]
    

    从您的输出中删除封闭的{ "events": ... },它应该可以工作

    【讨论】:

    • 没有成功。我的 json 文件现在有这种格式的输出 [{"start":"2015-11-09 01:30:00","end":"2015-11-09 02:30:00","title":"与教授会面"},....]
    • ${pageContext.request.contextPath}/calendarFetch 可能是扩展路径不对?当您查看页面源时,如果您将事件 url 复制到浏览器并转到那里,您会看到事件 json 吗?
    猜你喜欢
    • 1970-01-01
    • 2017-10-21
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2015-07-05
    • 1970-01-01
    • 1970-01-01
    相关资源
    最近更新 更多