@Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {
    modifyNoticeForm f = (modifyNoticeForm) form;

    Session s = HibernateSessionFactory.getSession();
    try {
      s.beginTransaction();
      // 获取当前时间
      SimpleDateFormat df = new SimpleDateFormat("yyyy-MM-dd HH:mm:ss");
      String time = df.format(new Date()).toString();

      Notice notice = (Notice) s.get(Notice.class, f.getNoticeid());
      notice.setChangetime(time);
      notice.setContent(f.getContent());
      notice.setTitle(f.getNoticetitle());
      s.save(notice);

      s.getTransaction().commit();
      s.close();
    } catch (Exception ex) {
      if (s.getTransaction() != null) s.getTransaction().rollback();
      ex.printStackTrace();
    }
    return mapping.findForward("success");
  }
  @Override
  public ActionForward execute(
      ActionMapping mapping,
      ActionForm form,
      HttpServletRequest request,
      HttpServletResponse response)
      throws Exception {

    PrintWriter out = response.getWriter();
    Session s = HibernateSessionFactory.getSession();

    String role = request.getParameter("role");
    if (role.equals("stu")) {
      Query query = s.createQuery("from Student");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Stupn = (Integer) request.getSession().getAttribute("Stupn");
      if (Stupn == null) {
        request.getSession().setAttribute("Stupn", 1);
        Stupn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + Stupn);
    } else if (role.equals("tea")) {
      Query query = s.createQuery("from Teacher");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Teapn = (Integer) request.getSession().getAttribute("Teapn");
      if (Teapn == null) {
        request.getSession().setAttribute("Teapn", 1);
        Teapn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + Teapn);
    } else if (role.equals("course")) {
      Query query = s.createQuery("from Course");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Coursepn = (Integer) request.getSession().getAttribute("Coursepn");
      if (Coursepn == null) {
        request.getSession().setAttribute("Coursepn", 1);
        Coursepn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + Coursepn);
    } else if (role.equals("uncheckedStu")) {
      Query query = s.createQuery("from Unchecked un where un.role='stu'");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer UncheckedStupn = (Integer) request.getSession().getAttribute("UncheckedStupn");
      if (UncheckedStupn == null) {
        request.getSession().setAttribute("UncheckedStupn", 1);
        UncheckedStupn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      //	System.out.println("limitstu:"+limit+"      uncheckedstupn:"+UncheckedStupn);
      out.println(limit + "," + UncheckedStupn);
    } else if (role.equals("uncheckedTea")) {
      Query query = s.createQuery("from Unchecked un where un.role='tea'");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer UncheckedTeapn = (Integer) request.getSession().getAttribute("UncheckedTeapn");
      if (UncheckedTeapn == null) {
        request.getSession().setAttribute("UncheckedTeapn", 1);
        UncheckedTeapn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + UncheckedTeapn);
    } else if (role.equals("admin")) {
      Query query = s.createQuery("from Admin");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Adminpn = (Integer) request.getSession().getAttribute("Adminpn");
      if (Adminpn == null) {
        request.getSession().setAttribute("Adminpn", 1);
        Adminpn = 1;
      }
      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + Adminpn);
    } else if (role.equals("teaCourse")) {

      String userid = (String) request.getSession().getAttribute("userid");
      Query query = s.createQuery("from Course c where c.teacher.id = '" + userid + "'");
      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Teacoursepn = (Integer) request.getSession().getAttribute("Teacoursepn");
      if (Teacoursepn == null) {
        request.getSession().setAttribute("Teacoursepn", 1);
        Teacoursepn = 1;
      }

      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + Teacoursepn);
    } else if (role.equals("stuRelCourse")) {
      String userid = (String) request.getSession().getAttribute("userid");
      Student student = (Student) s.get(Student.class, userid);
      List<Course> allCourses = new ArrayList(student.getCourses());

      int listNum = allCourses.size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer StuRelcoursepn = (Integer) request.getSession().getAttribute("StuRelcoursepn");
      if (StuRelcoursepn == null) {
        request.getSession().setAttribute("StuRelcoursepn", 1);
        StuRelcoursepn = 1;
      }

      int limit = totalPage + 1;
      if (listNum == 0) limit = 2;
      out.println(limit + "," + StuRelcoursepn);
    } else if (role.equals("stuAllCourse")) {
      Query query = s.createQuery("from Course");

      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer StuAllcoursepn = (Integer) request.getSession().getAttribute("StuAllcoursepn");
      if (StuAllcoursepn == null) {
        request.getSession().setAttribute("StuAllcoursepn", 1);
        StuAllcoursepn = 1;
      }

      int limit = totalPage + 1;

      if (listNum == 0) limit = 2;
      out.println(limit + "," + StuAllcoursepn);
    } else if (role.equals("stuAllNotice")) {
      Query query = s.createQuery("from Notice");

      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer StuAllnoticepn = (Integer) request.getSession().getAttribute("StuAllnoticepn");
      if (StuAllnoticepn == null) {
        request.getSession().setAttribute("StuAllnoticepn", 1);
        StuAllnoticepn = 1;
      }

      int limit = totalPage + 1;

      if (listNum == 0) limit = 2;
      out.println(limit + "," + StuAllnoticepn);
    } else if (role.equals("homework")) {
      s.beginTransaction();
      Integer taskid = (Integer) request.getSession().getAttribute("homeworktaskid");
      Task task = (Task) s.get(Task.class, taskid);

      request.setAttribute("tasktitle", task.getTitle());

      Query query = s.createQuery("from Work wk where taskid = '" + taskid + "'");

      int listNum = query.list().size();
      int totalPage = listNum / PageItemNum;
      if (listNum % PageItemNum != 0) totalPage++;

      Integer Homeworkpn = (Integer) request.getSession().getAttribute("Homeworkpn");
      if (Homeworkpn == null) {
        request.getSession().setAttribute("Homeworkpn", 1);
        Homeworkpn = 1;
      }

      int limit = totalPage + 1;

      if (listNum == 0) limit = 2;
      out.println(limit + "," + Homeworkpn);
    }

    out.flush();
    out.close();
    s.close();

    return super.execute(mapping, form, request, response);
  }