在fullcalendar中不显示DB中的事件

时间:2015-05-04 11:37:35

标签: java jquery fullcalendar

我是第一次尝试在fullcalendar(v2.0.0)中更新DB中的事件。这是我试过的代码,

$('#calendar').fullCalendar({
        editable: true,
        events:"/FullcalendarProject/FullCalendarChecking",
        eventDrop : function(event,revertFunc){
             //here my $ajax(){ update DB }
        }

});

FullCalendarChecking.java

protected void doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
        List l = new ArrayList();

        PreparedStatement st = null;
        ResultSet rst = null;
        Connection con = null;

        try
        {
            Class.forName("com.mysql.jdbc.Driver");
            con = DriverManager.getConnection("jdbc:mysql://localhost:3306/raptor1_5","root","");
            String query="select * from tblplanner where User_id=?";
            st = con.prepareStatement(query);
            st.setString(1, "112");
            rst =st.executeQuery();

            String prepand="{title: ";
            String st1="start: ";
            String postpand="}";


            while(rst.next())
            {
                System.out.println("entered...");
                String plannedDate =rst.getString("date"); // this will be start in fullcalendar


                String plannedChapter =rst.getString("chapter"); // this will be title in fullcalendar
                System.out.println(plannedDate);

                String afterchange =prepand+"'"+plannedChapter+"'"+","+st1+"'"+plannedDate+"'"+postpand;
                l.add(afterchange);


            }

        }
        catch(Exception e)
        {
            e.printStackTrace();

        }

        finally
        {
            try{
            con.close();
            rst.close();
            }
            catch(Exception e)
            {
                e.printStackTrace();
            }
        }

        System.out.println(l);

         response.setContentType("application/json");
         response.setCharacterEncoding("UTF-8");
         PrintWriter out = response.getWriter();
         out.println(new Gson().toJson(l));

    }   

输出JSON:

["{title: \u0027Plants\u0027,start: \u00272015-04-28\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-10\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-12\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-13\u0027}","{title: \u0027Plants\u0027,start: \u00272015-05-08\u0027}","{title: \u0027Animals\u0027,start: \u00272015-05-12\u0027}"]

enter image description here

为什么所有活动都会在今天的日期显示并显示当前时间而不是标题?

我在哪里做错了?

0 个答案:

没有答案