Beispiel #1
0
  public Result ask(HttpServletRequest req, HttpServletResponse resp)
      throws ServletException, IOException {
    String comment = req.getParameter("comment");
    if (!validate(comment)) {
      req.getRequestDispatcher("/jsp/query/ask.jsp").forward(req, resp);
      return Result.error();
    }

    String type = req.getParameter("type");
    if (type.equals("still ask")) {
      doAsk(comment, req);
      return search(req, resp);
    }

    Paging<Comment> list = doSearch(comment, req, resp);
    if (list.data.isEmpty()) {
      doAsk(comment, req);
      return search(req, resp);
    }

    hesitate(comment, req, resp);
    req.getRequestDispatcher("/jsp/query/ask.jsp").forward(req, resp);
    return Result.ok();
  }