有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java如何使用servlet从数据库中获取日期并放入fullcalendar

我是第一次在应用程序中使用fullcalendar。我只是想把所有事件从DB放到fullcalendar。这是我的代码我试过了

MyJsp.jsp

        $('#calendar').fullCalendar({
                //defaultDate: '2015-02-12',
                editable: true,
                events: "/FullcalendarProject/FullCalendarChecking"
        });

完整日历检查。爪哇

    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();

                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
                    l.add(plannedDate);
                    l.add(plannedChapter);
                    //here i am doing woring..?!!
                }

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

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


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

        }

但是这个代码并不像我期望的那样工作

输出:

all fetched dates dsiaplays in todays date

预期产量:

all fetched dates show in its own date

MyTable:

用户id章节日期

112第1章2015-04-27

112第2章2015-04-29

112第3章2015-04-30

怎么做


共 (0) 个答案