那里。我第一次尝试将完整日历与JSP Servlet和MySQL集成。现在只是试图让它在没有数据库连接的情况下工作。我无法在日历中看到事件......
eventCalendar.jsp
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>Timetable</title>
<link rel='stylesheet' href='fullcalendar/fullcalendar.css' />
<script src='fullcalendar/lib/jquery.min.js'></script>
<script src='fullcalendar/lib/moment.min.js'></script>
<script src='fullcalendar/fullcalendar.js'></script>
<script>
$(document).ready(function () {
// page is now ready, initialize the calendar...
$('#calendar').fullCalendar({
// put your options and callbacks here
events: "calendarServlet",
dayClick: function () {
alert('a day has been clicked!');
}
})
});
</script>
</head>
calendarServlet.java
protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
List l = new ArrayList();
CalendarDTO c = new CalendarDTO();
c.setId(1);
c.setStart("2017-01-26");
c.setEnd("2017-01-27");
c.setTitle("Task in Progress");
CalendarDTO d = new CalendarDTO();
c.setId(2);
c.setStart("2017-01-24");
c.setEnd("2017-01-25");
c.setTitle("Task in Progress");
l.add(c);
l.add(d);
String json = new Gson().toJson(l);
response.setContentType("application/json");
response.setCharacterEncoding("UTF-8");
response.getWriter().write(json);
}
我在Chrome开发者工具中获得:
Uncaught TypeError: Cannot read property 'hasTime' of undefined
at normalizeEventTimes (fullcalendar.js:12272)
at normalizeEventDates (fullcalendar.js:12252)
at assignDatesToEvent (fullcalendar.js:12243)
at buildEventFromInput (fullcalendar.js:12227)
at fullcalendar.js:11624
at Object.success (fullcalendar.js:11754)
at i (jquery.min.js:2)
at Object.fireWith [as resolveWith] (jquery.min.js:2)
at A (jquery.min.js:4)
at XMLHttpRequest.<anonymous> (jquery.min.js:4)
normalizeEventTimes @ fullcalendar.js:12272
normalizeEventDates @ fullcalendar.js:12252
assignDatesToEvent @ fullcalendar.js:12243
buildEventFromInput @ fullcalendar.js:12227
(anonymous) @ fullcalendar.js:11624
success @ fullcalendar.js:11754
i @ jquery.min.js:2
fireWith @ jquery.min.js:2
A @ jquery.min.js:4
(anonymous) @ jquery.min.js:4
答案 0 :(得分:0)
我发现了一个错误:
CalendarDTO d = new CalendarDTO();
c.setId(2);
c.setStart("2017-01-24");
c.setEnd("2017-01-25");
c.setTitle("Task in Progress");
应该是
CalendarDTO d = new CalendarDTO();
d.setId(2);
d.setStart("2017-01-24");
d.setEnd("2017-01-25");
d.setTitle("Task in Progress");