βΆ μλ°λΉμ μ΄μ©ν νμ κ°μ νΌ μμ±
β
1. μλ°λΉμ μμ±
β
JoinBean.java
package join;
public class JoinBean {
private String id;
private String pass;
private String name;
private int sex;
private int age;
private String email;
public String getId() {
return id;
}
public void setId(String id) {
this.id = id;
}
public String getPass() {
return pass;
}
public void setPass(String pass) {
this.pass = pass;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
public int getSex() {
return sex;
}
public void setSex(int sex) {
this.sex = sex;
}
public int getAge() {
return age;
}
public void setAge(int age) {
this.age = age;
}
public String getEmail() {
return email;
}
public void setEmail(String email) {
this.email = email;
}
}
-μ¬κΈ°μ μλ°λΉμ μν μ νμ κ°μ ν λ μ λ ₯νλ λ΄μ©μ λ©€λ² λ³μμ μ μ₯νλ μν μ νλ€.
β
β
2. μ λ ₯νΌ νμ΄μ§μ μμ±
β
joinForm.jsp (μ€ν νμ΄μ§)
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>νμ κ°μ
νΌ</title>
<style>
#formArea {
margin:auto;
width:400px;
border:1px solid gray;
text-align:center;
}
h1 {
text-align:center;
}
table {
width:380px;
margin:auto;
text-align:center;
}
</style>
</head>
<body>
<section id="formArea">
<h1>νμμ 보 μ
λ ₯</h1>
<form action="joinChk.jsp" method="post">
<table>
<tr>
<td><label for="id">μμ΄λ : </label></td>
<td><input type="text" name="id" id="id"></td>
</tr>
<tr>
<td><label for="pass">λΉλ°λ²νΈ : </label></td>
<td><input type="password" name="pass" id="pass"></td>
</tr>
<tr>
<td><label for="name">μ΄λ¦ : </label></td>
<td><input type="text" name="name" id="name"></td>
</tr>
<tr>
<td><label for="sex">μ±λ³ : </label></td>
<td><input type="radio" name="sex" value="1" id="sex" checked>λ¨
<input type="radio" name="sex" value="2">μ¬</td>
</tr>
<tr>
<td><label for="age">λμ΄ : </label></td>
<td><input type="text" name="age" id="age"></td>
</tr>
<tr>
<td><label for="email">μ΄λ©μΌμ£Όμ : </label></td>
<td><input type="text" name="email" id="email"></td>
</tr>
<tr>
<td colspan="2">
<input type="submit" value="κ°μ
">
<input type="reset" value="λ€μ μμ±">
</td>
</tr>
</table>
</form>
</section>
</body>
</html>
-μ΄ νμ΄μ§λ μμ΄λ, λΉλ°λ²νΈ λ± νμ κ°μ μ νμν μ 보λ€μ μ λ ₯ λ°κ³ <κ°μ > λ²νΌμ λλ₯΄λ©΄ μ λ ₯ μ 보 νμΈ νμ΄μ§λ‘ μ΄λνλ€.
β
β
3. μ λ ₯ μ 보 νμΈ νμ΄μ§μ μμ±
β
joinChk.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%request.setCharacterEncoding("UTF-8"); %>
<jsp:useBean id="join" class="join.JoinBean"/>
<jsp:setProperty name="join" property="*"/>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>νμ κ°μ
μ
λ ₯ μ 보 νμΈ νμ΄μ§</title>
<style type="text/css">
table {
width: 400px;
}
h1 {
text-align: center;
}
</style>
</head>
<body>
<table>
<tr>
<td><b>μμ΄λ : </b></td>
<td><jsp:getProperty name="join" property="id"/></td>
</tr>
<tr>
<td><b>λΉλ°λ²νΈ : </b></td>
<td><jsp:getProperty name="join" property="pass"/></td>
</tr>
<tr>
<td><b>μ΄λ¦ : </b></td>
<td><jsp:getProperty name="join" property="name"/></td>
</tr>
<tr>
<td><b>μ±λ³ : </b></td>
<td><jsp:getProperty name="join" property="sex"/></td>
</tr>
<tr>
<td><b>λμ΄ : </b></td>
<td><jsp:getProperty name="join" property="age"/></td>
</tr>
<tr>
<td><b>μ΄λ©μΌμ£Όμ : </b></td>
<td><jsp:getProperty name="join" property="email"/></td>
</tr>
</table>
</body>
</html>
-μ λ ₯ μ 보 νμΈ νμ΄μ§μμλ νμ κ°μ μ 보λ₯Ό <jsp:setProperty/> νκ·Έλ₯Ό μ΄μ©νμ¬ μλ°λΉ κ°μ²΄μ μ μ₯νκ³ , μ μ₯ν λ΄μ©μ <jsp:getProperty/> νκ·Έλ₯Ό μ΄μ©νμ¬ νμνλ μ½λλ₯Ό μμ±νλ€.
β
β
<μ€ν κ²°κ³Ό>
-μμμμ²λΌ νμ κ°μ νΌμμ μ λ ₯ λ°μ μλ£λ€μ <jsp:setProperty/> νκ·Έλ₯Ό μ΄μ©νμ¬ νλμ© ν λΉνμ§ μλλΌλ ν μ€μ μ½λλ‘ λͺ¨λ λ°μ΄ν°λ₯Ό ν λ²μ μ λ ₯μν¬ μ μλ€.
'JSP' μΉ΄ν κ³ λ¦¬μ λ€λ₯Έ κΈ
[JSP] μ€μ΅ (Session scopeλ₯Ό μλ°λΉμμ μ¬μ©νκΈ°) (0) | 2021.02.25 |
---|---|
[JSP] μ€μ΅ (Request scopeλ₯Ό μλ°λΉμμ μ¬μ©νκΈ°) (0) | 2021.02.24 |
[JSP] JSPμμ μλ°λΉ μ¬μ©νκΈ° (0) | 2021.02.24 |
[JSP] μλ°λΉ (0) | 2021.02.24 |
[JSP] μ‘μ νκ·Έλ₯Ό νμ©ν ν νλ¦Ώ νμ΄μ§ μμ± (0) | 2021.02.10 |
λκΈ