Beispiel #1
0
  @Override
  public void service(ServletRequest request, ServletResponse response)
      throws ServletException, IOException {

    Board board = new Board();
    board.setTitle(request.getParameter("title"));
    board.setContent(request.getParameter("content"));
    board.setPassword(request.getParameter("password"));

    PrintWriter out = response.getWriter();
    BoardDao boardDao = ContextLoader.context.getBean(BoardDao.class);
    boardDao.insert(board);
    out.println("저장되었습니다.");
  }
  public void service(HashMap<String, Object> params) {
    Board board = new Board();
    board.setNo(Integer.parseInt((String) params.get("no")));
    board.setTitle((String) params.get("title"));
    board.setContent((String) params.get("content"));
    board.setPassword((String) params.get("password"));

    PrintStream out = (PrintStream) params.get("out");

    if (boardDao.update(board) > 0) {
      out.println("변경되었습니다.");
    } else {
      out.println("해당 게시물이 존재하지 않거나 암호가 맞지 않습니다.");
    }
  }