当获取时间如9:00时,getparameter返回null jsp

时间:2014-03-05 09:46:48

标签: database jsp

    PreparedStatement pstmt = conn
            .prepareStatement("INSERT INTO discussion(section_id, weekday, room, mandatory, starttime,endtime) VALUES ( ?, ?, ?, ?, ?, ?)");

    pstmt.setInt(1, Integer.parseInt(request.getParameter("SECTION_ID")));
    pstmt.setString(2, request.getParameter("WEEKDAY"));
    pstmt.setString(3, request.getParameter("ROOM"));
    pstmt.setString(4, request.getParameter("MANDATORY"));

    String TIME_FORMAT = "HH:mm";
    SimpleDateFormat timeFormat = new SimpleDateFormat(TIME_FORMAT,
            Locale.getDefault());

    out.println("Items: " + request.getParameter("starttime"));
    out.println("Items: " + request.getParameter("WEEKDAY"));
    pstmt.setTime(5,
            new Time(timeFormat.parse(request.getParameter("starttime"))
                    .getTime()));
    pstmt.setTime(6,
            new Time(timeFormat.parse(request.getParameter("endtime"))
                    .getTime()));
    pstmt.executeUpdate();

我使用out.print进行测试。发现getparameter工作不对。它可以给我工作日数据但不能给我开始时间数据。数据库给出了开始时间类型

0 个答案:

没有答案