userList.jsp ํ๋จ์ [๋ช ๋จ ๋ณด๊ธฐ] ๋ฒํผ์ ์์ฑํ๊ณ ๊ทธ ๋ฒํผ์ ํด๋ฆญํ๋ฉด alert ์ ๋ชจ๋ ์ด์ฉ์์ ์ด๋ฆ์ด ํ์๋๋๋ก ํ๋ผ
์๋ฒ์ธก์์ ๋ชจ๋ ์ด๋ฆ์ ๊ตฌํ์ฌ JSON๋ฐฐ์ด ํ์์ ๋ฌธ์์ด๋ก ์๋ตํ๋ฉด ์๋ฐ์คํฌ๋ฆฝํธ์์๋ ๊ทธ ๋ฌธ์์ด์ ์์ ํ์ฌ JSON.parse(str)๋ฅผ ์ฌ์ฉํ์ฌ ์๋ฐ์คํฌ๋ฆฝํธ๋ฐฐ์ด์ ์ฌ์ฉํ ์ ์๋ค.
java๋ฅผ ์ฌ์ฉํ json๋ฐฐ์ด ํ์์ ๋ฌธ์์ด ์์ฑ๋ฒ
String strArr = "[\"Smith\", \"Mary\"]" (๋ฐธ๋ฅ์ ์ฐ์)
out.println(strArr)
json simple ๋ผ์ด๋ธ๋ฌ๋ฆฌ์ jsonarray ํด๋์ค๋ฅผ ์ฌ์ฉํ๋ฉด ์ฝ๊ฒ json๋ฐฐ์ด์ ํ์์ ๋ฌธ์์ด ์์ฑ ๊ฐ๋ฅ
๋ฌธ์์ด >1 json ์ค๋ธ์ ํธ
>2 json ๋ฐฐ์ด
์๋ฒ์์ ํ ์คํธ๋ฅผ ๋ณด๋ด์ ๋ธ๋ผ์ฐ์ ์์ ๊ฐ์ฒด๋ก์ ๋ถ๋ฆด ์ ์๋ค.
ํ ์คํธ๋ฅผ ๊ฐ์ฒดํํด์ ์ฐ๋ฉด ์ข์ ์ ์ ํ ์คํธ ์์ ๋ง์ ํค์ ๋ฐธ๋ฅ๋ค์ ์ถ์ถํ๊ธฐ ํธํ๊ณ ๋ค๋ฃจ๊ธฐ ํธํ๋ค.
userList.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
|
<%@page import="com.ezen.web.hello.User"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% List<User> list = (List<User>) request.getAttribute("list"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ ์ฅ๋ ์ด์ฉ์ ๋ชฉ๋ก ๋ณด๊ธฐ</title>
<style type="text/css">
table { border: 1px solid black; border-spacing:1px;
border-collapse:collapse; padding:0.3em;}
th{background-color:#eee; border-bottom:3px double black;}
th,td{padding:0.2em 1em; border-right:1px dashed black;}
td{border-bottom: 1px dashed black;}
</style>
<script type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
</head>
<body>
<table>
<tr><th>๋ฒํธ</th><th>์ด๋ฆ</th><th>์ ํ</th><th>์ด๋ฉ์ผ</th></tr>
<%
for(int i =0;i<list.size();i++){
User u = list.get(i);
int num = u.getNum();
String name = u.getName();
String phone = u.getPhone();
String email = u.getEmail();
%>
<tr>
<td><%=num %></td>
<td><a href="userc?cmd=detail&num=<%=num%>"><%=name%></a></td>
<td><%=phone %></td>
<td><%=email %></td>
</tr>
<% } %>
</table>
<form action="userc" method="post">
<input type="hidden" name="cmd" value="findByName">
<label>์ด๋ฆ์ผ๋ก ๊ฒ์</label><input type="text" name="name">
<button type="submit">[๊ฒ์]</button>
<script>
function showList(){
$.ajax({
url:'userc',
method:'post',
data : {"cmd":"namelist"},
dataType: 'json',
cache : false,
success: function(res){
alert(res);
},
err:function(xhr, status, err){
alert(err);
}
});
}
</script>
<button type="button" onclick="showList();">๋ช
๋จ ๋ณด๊ธฐ</button>
[<a href="userc?cmd=regForm"> ์ด์ฉ์ ์ ๋ณด ๋ฑ๋ก ๊ฐ๊ธฐ </a>]
<div><output id='out'></output></div>
</form>
</body>
</html>
|
cs |
userController ํด๋์ค
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
|
import java.io.IOException;
import java.io.PrintWriter;
import java.util.List;
import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;
import org.json.simple.JSONArray;
import org.json.simple.JSONObject;
@WebServlet("/userc")
public class UserController extends HttpServlet {
protected void service(HttpServletRequest request, HttpServletResponse response)
throws ServletException, IOException
{
response.setContentType("text/html; charset=utf-8");
request.setCharacterEncoding("utf-8");
String cmd = request.getParameter("cmd");
if(cmd==null ||cmd.equals("list"))
{
UserService svc = new UserService(request);
List<User> list = svc.getlist();
request.setAttribute("list", list);
getServletContext().getRequestDispatcher("/userlist.jsp").forward(request, response);
}
else if(cmd.equals("regForm"))
{
getServletContext().getRequestDispatcher("/userRegForm.jsp").forward(request, response);
}else if(cmd.equals("namelist"))
{
UserService svc = new UserService(request);
PrintWriter out =response.getWriter();
out.println(svc.getNameList());
out.flush();
}
else if(cmd.equals("reg"))
{
UserService svc = new UserService(request);
boolean saved = svc.save();
PrintWriter out =response.getWriter();
//String json ="{\"saved\":"+saved+"}";
JSONObject jsobj = new JSONObject();
jsobj.put("saved",saved);
out.println(jsobj.toJSONString());
out.flush();
//getServletContext().getRequestDispatcher("/userRegResult.jsp").forward(request, response);
}
else if(cmd.equals("detail"))
{
UserService svc = new UserService(request);
User u = svc.getUser();
request.setAttribute("u", u);
getServletContext().getRequestDispatcher("/userDetail.jsp").forward(request, response);
}else if(cmd.equals("edit"))
{
UserService svc = new UserService(request);
User u = svc.getUser();
request.setAttribute("u", u);
getServletContext().getRequestDispatcher("/userupdate.jsp").forward(request, response);
}
else if(cmd.equals("findByName"))
{
UserService svc = new UserService(request);
List<User> list = svc.findUser();
request.setAttribute("list", list);
getServletContext().getRequestDispatcher("/userfind.jsp").forward(request, response);
}else if(cmd.equals("update"))
{
UserService svc = new UserService(request);
boolean update = svc.userUpdate();
PrintWriter out =response.getWriter();
String json ="{\"update\":"+update+"}";
out.println(json);
out.flush();
// \ : ์ด์ค์ผ์ดํ ๋ฌธ์ - ์๋ ๊ฐ์ง ๊ธฐ๋ฅ์์ ๋ฒ์ด๋๊ฒ ํจ
//request.setAttribute("update", update);
//getServletContext().getRequestDispatcher("/updateResult.jsp").forward(request, response);
}else if(cmd.equals("delete"))
{
UserService svc = new UserService(request);
boolean delete = svc.userDelete();
//request.setAttribute("delete", delete);
JSONObject jsobj = new JSONObject();
PrintWriter out =response.getWriter();
jsobj.put("delete",delete);
out.println(jsobj.toJSONString());
out.flush();
//getServletContext().getRequestDispatcher("/userDelete.jsp").forward(request, response);
}else {
System.err.println("์ค๋ฅ๊ฐ ๋ฐ์๋์์ต๋๋ค.");
}
}
}
|
cs |
userService ํด๋์ค
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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
|
import java.io.FileOutputStream;
import java.io.*;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.List;
import javax.servlet.http.HttpServletRequest;
import org.json.simple.JSONArray;
public class UserService
{
private HttpServletRequest request;
private String fpath = "D:/java_test/user.ser";
public UserService(HttpServletRequest request)
{
this.request = request;
}
public boolean save()
{
User u = new User();
u.setNum(Integer.parseInt(request.getParameter("num")));
u.setName(request.getParameter("name"));
u.setPhone(request.getParameter("phone"));
u.setEmail(request.getParameter("email"));
File f = new File(fpath);
List<User> list = null;
if(!f.exists()) list = new ArrayList<>();
else list = deserialize();
list.add(u);
return serialize(list);
}
private boolean serialize(List<User> list)
{
try {
ObjectOutputStream objOut = new ObjectOutputStream(new FileOutputStream(fpath));
objOut.writeObject(list);
objOut.close();
return true;
} catch (Exception e) {
e.printStackTrace();
}
return false;
}
public String getNameList()
{
List<User> list = deserialize();
JSONArray jsArr = new JSONArray();
for(int i=0;i<list.size();i++) {
jsArr.add(list.get(i).getName());
}
return jsArr.toJSONString();
}
public User getUser()
{
int num = Integer.parseInt(request.getParameter("num"));
List<User> list = deserialize();
User key = new User(num);
if(list.contains(key)) {
return list.get(list.indexOf(key));
}
return null;
}
public List<User> findUser()
{
String key = request.getParameter("name");
List<User> list = deserialize();
List<User> found = new ArrayList<>();
for(int i=0;i<list.size();i++) {
if(list.get(i).getName().equals(key)) {
found.add(list.get(i));
}
}
if(found.size()==0) found = null;
return found;
}
public boolean userUpdate()
{
int num = Integer.parseInt(request.getParameter("num"));
String email = request.getParameter("email");
List<User> list = deserialize();
User key = new User(num);
if(list.contains(key)) {
list.get(list.indexOf(key)).setEmail(email);
serialize(list);
return true;
}
return false;
}
public boolean userDelete()
{
int num = Integer.parseInt(request.getParameter("num"));
List<User> list = deserialize();
User key = new User(num);
if(list.contains(key)) {
list.remove(list.indexOf(key));
serialize(list);
return true;
}
return false;
}
private List<User> deserialize()
{
try {
ObjectInputStream objInput = new ObjectInputStream(new FileInputStream(fpath));
List<User> list = (List<User>)objInput.readObject();
objInput.close();
return list;
} catch (Exception e) {
e.printStackTrace();
}
return null;
}
public List<User> getlist() {
return deserialize();
}
}
|
cs |
์คํ ๊ฒฐ๊ณผ:
userList.jsp์์ 54์ด์ ์์ ํ์ฌ
$('#out').val(JSON.stringify(res));
์ด๋ ๊ฒ ์คํํ๋ค๋ฉด ๋ค์๊ฐ์ด ๋์จ๋ค.
userList.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
|
<%@page import="com.ezen.web.hello.User"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% List<User> list = (List<User>) request.getAttribute("list"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ ์ฅ๋ ์ด์ฉ์ ๋ชฉ๋ก ๋ณด๊ธฐ</title>
<style type="text/css">
table { border: 1px solid black; border-spacing:1px;
border-collapse:collapse; padding:0.3em;}
th{background-color:#eee; border-bottom:3px double black;}
th,td{padding:0.2em 1em; border-right:1px dashed black;}
td{border-bottom: 1px dashed black;}
</style>
<script type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
</head>
<body>
<table>
<tr><th>๋ฒํธ</th><th>์ด๋ฆ</th><th>์ ํ</th><th>์ด๋ฉ์ผ</th></tr>
<%
for(int i =0;i<list.size();i++){
User u = list.get(i);
int num = u.getNum();
String name = u.getName();
String phone = u.getPhone();
String email = u.getEmail();
%>
<tr>
<td><%=num %></td>
<td><a href="userc?cmd=detail&num=<%=num%>"><%=name%></a></td>
<td><%=phone %></td>
<td><%=email %></td>
</tr>
<% } %>
</table>
<form action="userc" method="post">
<input type="hidden" name="cmd" value="findByName">
<label>์ด๋ฆ์ผ๋ก ๊ฒ์</label><input type="text" name="name">
<button type="submit">[๊ฒ์]</button>
<script>
function showList(){
$.ajax({
url:'userc',
method:'post',
data : {"cmd":"namelist"},
dataType: 'json',
cache : false,
success: function(res){
//alert(res);
//$('#out').val(JSON.stringify(res));
//$('#out').text(JSON.stringify(res));
$('#uid').val('MyId');
$('#desc').text('๋ฐ๊ฐ์ต๋๋ค.');
},
err:function(xhr, status, err){
alert(err);
}
});
}
</script>
<button type="button" onclick="showList();">๋ช
๋จ ๋ณด๊ธฐ</button>
[<a href="userc?cmd=regForm"> ์ด์ฉ์ ์ ๋ณด ๋ฑ๋ก ๊ฐ๊ธฐ </a>]
<div id="out"></div>
<div>์์ด๋<input type="text" id="uid"></div>
<div>์ ๊ฐ<span id="desc"></span></div>
</form>
</body>
</html>
|
cs |
์คํ๊ฒฐ๊ณผ:
userList.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
|
<%@page import="com.ezen.web.hello.User"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% List<User> list = (List<User>) request.getAttribute("list"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ ์ฅ๋ ์ด์ฉ์ ๋ชฉ๋ก ๋ณด๊ธฐ</title>
<style type="text/css">
table { border: 1px solid black; border-spacing:1px;
border-collapse:collapse; padding:0.3em;}
th{background-color:#eee; border-bottom:3px double black;}
th,td{padding:0.2em 1em; border-right:1px dashed black;}
td{border-bottom: 1px dashed black;}
</style>
<script type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
</head>
<body>
<table>
<tr><th>๋ฒํธ</th><th>์ด๋ฆ</th><th>์ ํ</th><th>์ด๋ฉ์ผ</th></tr>
<%
for(int i =0;i<list.size();i++){
User u = list.get(i);
int num = u.getNum();
String name = u.getName();
String phone = u.getPhone();
String email = u.getEmail();
%>
<tr>
<td><%=num %></td>
<td><a href="userc?cmd=detail&num=<%=num%>"><%=name%></a></td>
<td><%=phone %></td>
<td><%=email %></td>
</tr>
<% } %>
</table>
<form action="userc" method="post">
<input type="hidden" name="cmd" value="findByName">
<label>์ด๋ฆ์ผ๋ก ๊ฒ์</label><input type="text" name="name">
<button type="submit">[๊ฒ์]</button>
<script> function showList(){
$.ajax({
url:'userc',
method:'post',
data : {"cmd":"namelist"},
dataType: 'json',
cache : false,
success: function(res){
//alert(res);
$('#out').val(JSON.stringify(res));
//$('#out').text(JSON.stringify(res));
},
err:function(xhr, status, err){
alert(err);
} });
}
</script>
<button type="button" onclick="showList();">๋ช
๋จ ๋ณด๊ธฐ</button>
[<a href="userc?cmd=regForm"> ์ด์ฉ์ ์ ๋ณด ๋ฑ๋ก ๊ฐ๊ธฐ </a>]
<div><output id='out'></output></div> //๋ฅํ๊ทธ๋ value๋ผ๋ ์์ฑ์ด ์๋ค.
</form>
</body>
</html>
|
cs |
select ํ๊ทธ์ ๋ด์ฉ์ด ๋ช ๋จ๋ณด๊ธฐ ๋ฒํผ์ ๋๋ ์ ๋ ์๋ฒ์ธก์ผ๋ก๋ถํฐ ๋ฐ์ ๋ช ๋จ์ผ๋ก ๋ณ๊ฒฝ๋๊ฒ ํด๋ณด๋ผ
userList.jsp ์ ํ๋ฉด์์ ์ด๋ฆ์ผ๋ก ๊ฒ์ํ๋ ๊ฒ์์ฐฝ์ ์๋ฒ์ธก์ผ๋ก ๋ถํฐ ๋ช ๋จ์ ๊ตฌํด์ ํ๋ฉด์ด ๋ธ๋ผ์ฐ์ ์ ๋ก๋๋ ๋ ๊ฒ์์ฐฝ์ ๋ช ๋จ์ด ์ ์๋ ์ ์๋๋ก ํด๋ณด๋ผ
userList.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
|
<%@page import="com.ezen.web.hello.User"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% List<User> list = (List<User>) request.getAttribute("list"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์ ์ฅ๋ ์ด์ฉ์ ๋ชฉ๋ก ๋ณด๊ธฐ</title>
<style type="text/css">
table { border: 1px solid black; border-spacing:1px;
border-collapse:collapse; padding:0.3em;}
th{background-color:#eee; border-bottom:3px double black;}
th,td{padding:0.2em 1em; border-right:1px dashed black;}
td{border-bottom: 1px dashed black;}
</style>
<script type="text/javascript"></script>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script>
$(function(){
showList();
});
</script>
</head>
<body>
<table>
<tr><th>๋ฒํธ</th><th>์ด๋ฆ</th><th>์ ํ</th><th>์ด๋ฉ์ผ</th></tr>
<%
for(int i =0;i<list.size();i++){
User u = list.get(i);
int num = u.getNum();
String name = u.getName();
String phone = u.getPhone();
String email = u.getEmail();
%>
<tr>
<td><%=num %></td>
<td><a href="userc?cmd=detail&num=<%=num%>"><%=name%></a></td>
<td><%=phone %></td>
<td><%=email %></td>
</tr>
<% } %>
</table>
<form action="userc" method="post">
<input type="hidden" name="cmd" value="findByName">
<label>์ด๋ฆ์ผ๋ก ๊ฒ์</label><input type="text" name="name" list= "namelist" autocomplete="off">
<button type="submit">[๊ฒ์]</button>
<script>
function showList(){
$.ajax({
url:'userc',
method:'post',
data : {"cmd":"namelist"},
dataType: 'json',
cache : false,
success: function(res){
var namelist = $('namelist');
var sel = $('#sel1');
for(var i =0;i<res.length;i++){
var opt = $('<option>'+ res[i] +'</option>');
sel.append(opt);
}
},
err:function(xhr, status, err){
alert(err);
}
});
}
</script>
<button type="button" onclick="showList();">๋ช
๋จ ๋ณด๊ธฐ</button>
[<a href="userc?cmd=regForm"> ์ด์ฉ์ ์ ๋ณด ๋ฑ๋ก ๊ฐ๊ธฐ </a>]
<select id= "sel1" name="subject">
</select>
<input list = "subjectlist">
<datalist id="namelist">
</datalist>
<ol>
<li>A</li>
<li>B</li>
</ol>
<ul>
<li>A</li>
<li>B</li>
</ul>
</form>
</body>
</html>
|
cs |
์คํ ๊ฒฐ๊ณผ:
์ด์ฉ์์ ์์ธ์ ๋ณด๋ฅผ ๋๋ ์ ๋ ์ฌ์ง๋ ๋์ค๊ฒ๋ ํด๋ณด๋ผ
webapp์ ์ด๋ฏธ์ง๋ฅผ ๋ด๋ ํด๋๋ฅผ ๋ง๋ค์ด์ ํด๋น ๋๋ ํ ๋ฆฌ์ ์ด๋ฏธ์ง๋ฅผ ๋ฃ๊ณ ์ฝ๋ฉํด์ค๋ค.
userDetail.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
|
<%@page import="com.ezen.web.hello.User"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<% User u = (User)request.getAttribute("u"); %>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>์์ธ๋ณด๊ธฐ</title>
<style type="text/css">
#container { border:1px solid black; padding:1em;
width:fit-content; margin:0 auto; }
label { display:inline-block; width:5em; margin-right:1em;
border-bottom:1px solid black; }
h3 {width:fit-content; margin:0.5em auto; }
</style>
<script src="https://code.jquery.com/jquery-3.6.1.min.js"
integrity="sha256-o88AwQnZB+VDvE9tvIXrMQaPlFFSUTR+nldQm1LuPXQ=" crossorigin="anonymous"></script>
<script type="text/javascript"></script>
<script>
function deleteUser(num)
{
if(!confirm("์ ๋ง๋ก ํ์ฌ ์ด์ฉ์ ์ ๋ณด๋ฅผ ์ญ์ ํ๊ฒ ์ต๋๊น?")) return;
var obj = {"cmd":"delete","num":num};
$.ajax({
url:'userc',
method:'post',
data: obj,
cache : false,
dataType: 'json',
success:function(res){
if(res.delete){
alert('์ด์ฉ์ ์ ๋ณด ์ญ์ ์ฑ๊ณต!');
location.href = "userc?cmd=list";
}else{
alert('์ฌ์ฉ์ ์ ๋ณด ์ญ์ ์คํจ');
}
},
err:function(xhr, status, err){
alert(err);
}
});
}
</script>
</head>
<body>
<h3>์ด์ฉ์ ์ ๋ณด ์์ธ๋ณด๊ธฐ</h3>
<div id= "container">
<div><label>๋ฒํธ</label> <span><%= u.getNum() %></span></div>
<div><label>์ด๋ฆ</label> <span><%= u.getName() %></span></div>
<div><label>์ ํ</label> <span><%= u.getPhone() %></span></div>
<div><label>์ด๋ฉ์ผ</label> <span><%= u.getEmail() %></span></div>
<div><img src="images/couple.jpg"></div>
</div>
[<a href="userc?cmd=list"> ๋ฑ๋ก๋ ์ด์ฉ์ ์ ๋ณด ๋ณด๊ธฐ </a>]
[<a href="userc?cmd=edit&num=<%=u.getNum()%>"> ์์ </a>]
[<a href="javascript:deleteUser(<%=u.getNum()%>);"> ์ญ์ </a>]
</body>
</html>
|
cs |
54์ด์์์ฒ๋ผ ํด๋๋ช ๊ณผ ์ด๋ฏธ์ง๋ช ์ ์ ์ผ๋ฉด ๋๋ค.
์คํ๊ฒฐ๊ณผ:
๋๊ธ