모델1 게시판 - 글수정 구현
http://injava.tistory.com/16 방법과의 차이점(장단점)을 학습
boardModifyForm.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <%@ page import="java.sql.*" %> <%@ page import="service.*" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>BOARD MODIFY FORM</title> </head> <body> <h1>BOARD MODIFY</h1> <% if(request.getParameter("boardNo") == null) { response.sendRedirect(request.getContextPath()+"/board/boardList.jsp"); } else { int boardNo = Integer.parseInt(request.getParameter("boardNo")); System.out.println("boardModify param boardNo:"+boardNo); BoardDao boardDao = new BoardDao(); Board board = boardDao.selectBoardByKey(boardNo); %> <form action="<%=request.getContextPath()%>/board/boardModifyAction.jsp" method="post"> <div>boardNo</div> <div><input name="boardNo" value="<%=board.getBoardNo()%>" type="text" readonly="readonly"/></div> <div>비밀번호확인: </div> <div><input name="boardPw" id="boardPw" type="password"/></div> <div>boardTitle : </div> <div><input name="boardTitle" value="<%=board.getBoardTitle()%>" id="boardTitle" type="text"/></div> <div>boardContent : </div> <div><textarea name="boardContent" id="boardContent" rows="5" cols="50"><%=board.getBoardContent()%></textarea></div> <div> <input type="submit" value="글수정"/> <input type="reset" value="초기화"/> </div> </form> <% } %> </body> </html> | cs |
boardModifyAction.jsp
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 | <%@ page language="java" contentType="text/html; charset=EUC-KR" pageEncoding="EUC-KR"%> <%@ page import="java.sql.*" %> <%@ page import="service.*" %> <!DOCTYPE html> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=EUC-KR"> <title>BOARD MODIFY ACTION</title> </head> <body> <% request.setCharacterEncoding("euc-kr"); if(request.getParameter("boardNo") == null || request.getParameter("boardPw") == null) { response.sendRedirect(request.getContextPath()+"/board/boardList.jsp"); } else { int boardNo = Integer.parseInt(request.getParameter("boardNo")); System.out.println("boardModifyAction param boardNo :"+boardNo); String boardPw = request.getParameter("boardPw"); System.out.println("boardModifyAction param boardPw :"+boardPw); String boardTitle = request.getParameter("boardTitle"); System.out.println("boardModifyAction param boardTitle :"+boardTitle); String boardContent = request.getParameter("boardContent"); System.out.println("boardModifyAction param boardContent :"+boardContent); Board board = new Board(); board.setBoardNo(boardNo); board.setBoardPw(boardPw); board.setBoardTitle(boardTitle); board.setBoardContent(boardContent); BoardDao boardDao = new BoardDao(); boardDao.updateBoard(board); response.sendRedirect(request.getContextPath()+"/board/boardView.jsp?boardNo="+boardNo); } %> </body> </html> | cs |
'P. 자바 미니 프로젝트 > 모델1 게시판' 카테고리의 다른 글
P.2.5 모델1 게시판 만들기5 - 글삭제 (0) | 2016.11.30 |
---|---|
P.2.4 모델1 게시판 만들기4 - 글내용 (0) | 2016.11.30 |
P.2.3 모델1 게시판 만들기3 - 글목록 (2) | 2016.11.30 |
P.2.2 모델1 게시판 만들기2 - 글입력 (1) | 2016.11.30 |
P.2.1 모델1 게시판 만들기1 - DAO클래스 (1) | 2016.11.30 |