4. 요청파라미터로 넘어온 값을 설정할 경우 property의 이름과 요청파라미터의 이름이 동일한 경우 param을 생략할 수 있다. -> <jsp:setProperty name="mto" property="name" />
접기
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd "> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> 고객 정보 등록 - setProperty 테스트<br> <form action="/myjsp/actiontag/register_customer.jsp" method="post"> <table> <tr> <td> ID : </td><td><input type="text" name="id"></td> </tr> <tr> <td>password : </td><td><input type="password" name="password"></td> </tr> <tr> <td>이름 : </td><td><input type="text" name="name"></td> </tr> <tr> <td>나이 :</td><td> <input type="text" name="age"></td> </tr> <tr> <td>이메일 : </td><td><input type="text" name="email"></td> </tr> <tr> <td colspan="2"><input type="submit" value="등록"></td> </tr> </table> </form> </body> </html>
접기
접기
<!-- session scope의 customerDTO를 useBean 태그를 이용해 lookup 해 출력 --> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%><jsp:useBean id="session_customerDTO" class="myjsp.dto.CustomerDTO" scope="session"/> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd "> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head>
<body> session scope요청 정보<p> ID : <%=session_customerDTO.getId() %><br> 패스워드 : <%=session_customerDTO.getPassword() %><br> 이름 : <%=session_customerDTO.getName() %><br> 나이 : <%=session_customerDTO.getAge() %><br> 이메일 : <%=session_customerDTO.getEmail() %><br> </body> </html>
접기
접기
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <!-- useBean태그 - customer dto, session 룩업 --> <% request.setCharacterEncoding("utf-8"); %><jsp:useBean id="session_customerDTO" class="myjsp.dto.CustomerDTO" scope="session"/> <jsp:setProperty name="session_customerDTO" property="id" param="id" /> <jsp:setProperty name="session_customerDTO" property="password" param="password" /> <jsp:setProperty name="session_customerDTO" property="name" param="name" /> <jsp:setProperty name="session_customerDTO" property="age" param="age" /> <jsp:setProperty name="session_customerDTO" property="email" param="email" />
<!-- <jsp:setProperty name="session_customerDTO" property="*" /> --><!-- 매칭되는 값을 이렇게 써서 다 사용할수도있다 --> <%-- session_customerDTO.setAge(Integer.parseInt(request.getParameter("age"))); session_customerDTO.setId(request.getParameter("id")); --%> <!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd "> <html> <head> <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"> <title>Insert title here</title> </head> <body> 요청 정보<br> ID : <%=session_customerDTO.getId() %><br> 패스워드 : <%=session_customerDTO.getPassword() %><br> 이름 : <%=session_customerDTO.getName() %><br> 나이 : <%=session_customerDTO.getAge() %><br> 이메일 : <%=session_customerDTO.getEmail() %><br> <a href = "/myjsp/actiontag/res2.jsp">res2.jsp</a> </body> </html>
접기