Notice
Recent Posts
Recent Comments
Link
«   2025/03   »
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
Tags
more
Archives
Today
Total
관리 메뉴

WON.dev

update_page 본문

JSP/MYbatis

update_page

GAWON 2023. 6. 1. 18:56
<%@page import="org.joonzis.ex.GreenVO"%>
<%@page import="java.util.List"%>
<%@page import="org.joonzis.ex.GreenDao"%>
<%@page import="java.sql.ResultSet"%>
<%@page import="java.sql.PreparedStatement"%>
<%@page import="java.sql.Connection"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>Insert title here</title>
<script type="text/javascript">
	function update(f){
		if(		f.pw.value == '' ||
				f.name.value == '' ||
				f.age.value == '' ||
				f.addr.value == ''){
			alert("모든 내용을 입력하세요");
			return;
		}
		f.action = 'update.jsp';
		f.submit();
	}
</script>
</head>
<body>   
   <%
      		request.setCharacterEncoding("utf-8");
            String id = request.getParameter("id");  
            // 파란색 id는 아이디 입력창에서 내가 직접 id 값을 입력한 것, String id는 이 페이지에서 사용하기 위한 변수를 선언을 한 것 
            
            
            // Ctrl + 메소드 클릭 : 메소드 구현한 파일(위치)로 이동
            // GreenDao.getInstance() : 객체
            
           	GreenVO dto = GreenDao.getInstance().getselectone(id);
            // 위에서 선언한 id를 데이터 1개 출력하기 위한 함수인 getSelectOne() 함수에다가 매개변수로 넘겨줌(값 전달해줌)
         
            pageContext.setAttribute("dto", dto);
      %>
  
   <br>

  <jsp:include page="index.jsp"/>
	
	<br><hr><br>
	
	<h1><%=id %> 회원의 데이터</h1>
	<form method="post">
		<table>
			<thead>
				<tr>
					<th>회원 번호</th>
					<th>아이디</th>
					<th>비밀번호</th>
					<th>이름</th>
					<th>나이</th>
					<th>주소</th>
					<th>가입일</th>
				</tr>
			</thead>
			<tbody>
				<c:choose>
					<c:when test="${empty dto }">
						<tr>
							<td colspan="7"><%=id %>회원 정보가 없습니다.</td>
						</tr>				
					</c:when>
					<c:otherwise>
						<tr>
							<td>
								${dto.idx }
								<input type="hidden" name="idx" value="${dto.idx }">
							</td>
							<td>
								${dto.id }
							</td>
							<td><input type="password" name="pw" value="${dto.pw }"></td>
							<td><input type="text" name="name" value="${dto.name }"></td>
							<td><input type="number" name="age" value="${dto.age }"></td>
							<td><input type="text" name="addr" value="${dto.addr }"></td>
							<td>
								${dto.reg_date }
							</td>
						</tr>
					</c:otherwise>
				</c:choose>
			</tbody>
			<tfoot>
				<tr>
					<th colspan="7">
						<input type="button" value="수정" onclick="update(this.form)">&nbsp;&nbsp;
						<input type="reset" value="다시 작성">
					</th>
				</tr>
			</tfoot>
		</table>
	</form>
</body>
</html>

'JSP > MYbatis' 카테고리의 다른 글

view_all  (0) 2023.06.01
update  (0) 2023.06.01
remove  (0) 2023.06.01
insert  (0) 2023.06.01
index  (0) 2023.06.01