コード例 #1
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");

    // 接收資料
    String reflectedNotmp = request.getParameter("reflectedNo");
    //		String reflectedId = request.getParameter("reflectedId");

    String authorDatetmp = request.getParameter("authorDate");

    // 驗證資料
    Map<String, String> errorMessage = new HashMap<String, String>();
    request.setAttribute("error", errorMessage);

    // 轉換資料
    int memberNo = 0;
    if (reflectedNotmp != null && reflectedNotmp.length() != 0) {
      memberNo = GlobalService.convertInt(reflectedNotmp);
      if (memberNo == -1000) {
        errorMessage.put("memberNo", "memberNo must be an integer");
      }
    }

    java.util.Date date = new java.util.Date();
    if (authorDatetmp != null && authorDatetmp.length() != 0) {
      date = GlobalService.convertDate(authorDatetmp);
      if (memberNo == -1000) {
        errorMessage.put("date", "date must be an date");
      }
    }

    // 呼叫Model
    HeroVO herovo = new HeroVO();
    herovo.setMemberNo(memberNo);

    // 根據Model執行結果導向View
    List<HeroVO> herovolist = heroservice.select(herovo);
    List<HealthDiaryVO> healthdiarylist = heroservice.selectday(memberNo, date);

    if (healthdiarylist != null) {
      request.setAttribute("herovo", herovolist.get(0));
      request.setAttribute("healthdiary", healthdiarylist.get(0));
      request.getRequestDispatcher("/backend/HeroManageDay.jsp").forward(request, response);
    } else {
      request.getRequestDispatcher("/backend/HeroManageError.jsp").forward(request, response);
    }
  }
コード例 #2
0
  @Override
  protected void doGet(HttpServletRequest request, HttpServletResponse response)
      throws ServletException, IOException {
    request.setCharacterEncoding("UTF-8");

    // 接收資料
    String id = request.getParameter("id");
    String pageNoTemp = request.getParameter("pageNo");

    // 驗證資料
    Map<String, String> errorMessage = new HashMap<String, String>();
    request.setAttribute("error", errorMessage);

    // 轉換資料

    int pageNo = 0;
    if (pageNoTemp != null && pageNoTemp.length() != 0) {
      pageNo = GlobalService.convertInt(pageNoTemp);
      if (pageNo == -1000) {
        errorMessage.put("pageNo", "pageNo must be an integer");
      }
    }
    if (!errorMessage.isEmpty()) {
      RequestDispatcher rd = request.getRequestDispatcher("/backend/HeroManage.jsp");
      rd.forward(request, response);
      return;
    }

    // 呼叫Model

    // 根據Model執行結果導向View

    ReflectPageVO reflectpagevo = reflectservice.getPage(pageNo, 5, id);

    if (reflectpagevo != null) {
      request.setAttribute("reflectpagevo", reflectpagevo);
      request.getRequestDispatcher("/backend/HeroManage.jsp").forward(request, response);
    } else {
      request.getRequestDispatcher("/backend/HeroManageError.jsp").forward(request, response);
    }
  }