<학생프로그램>
<com.example.domain>-<StudentsVO.java>
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
|
package com.example.domain;
import java.util.Date;
public class StudentsVO {
private String scode;
private String sname;
private String dept;
private String year;
private Date Birthday;
private String advisor;
private String pname;
public String getScode() {
return scode;
}
public void setScode(String scode) {
this.scode = scode;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public String getYear() {
return year;
}
public void setYear(String year) {
this.year = year;
}
public Date getBirthday() {
return Birthday;
}
public void setBirthday(Date birthday) {
Birthday = birthday;
}
public String getAdvisor() {
return advisor;
}
public void setAdvisor(String advisor) {
this.advisor = advisor;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
@Override
public String toString() {
return "StudentsVO [scode=" + scode + ", sname=" + sname + ", dept=" + dept + ", year=" + year + ", Birthday="
+ Birthday + ", advisor=" + advisor + ", pname=" + pname + "]";
}
}
|
<com.example.persistence>-<StudentsDAO.Imterface>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package com.example.persistence;
import java.util.List;
import com.example.domain.Criteria;
public interface StudentsDAO {
public List<StudentsVO> list(Criteria cri)throws Exception;
public int total()throws Exception;
public void insert(StudentsVO vo) throws Exception;
public StudentsVO read(String scode) throws Exception;
public void update(StudentsVO vo) throws Exception;
public void delete(String scode) throws Exception;
}
|
<src/main/resource>-<mappers>-<StudentsMapper.xml>
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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
<mapper namespace="StudentsMapper">
select s.*,pname from students s,professors where advisor=pcode
limit #{pageStart}, #{perPageNum}
</select>
<select id="total" resultType="int">
select count(*) from students
</select>
<insert id="insert">
insert into students(scode, sname, dept, advisor,birthday,year)
values (#{scode},#{sname},#{dept},#{advisor},#{birthday},#{year})
</insert>
select * from students
where scode=#{scode}
</select>
<update id="update">
update students
set sname=#{sname},dept=#{dept},year=#{year}
where scode=#{scode}
</update>
<delete id="delete">
delete from students
where scode=#{scode}
</delete>
</mapper>
|
<com.example.persistence>-<StudentsDAOImpl.java>
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
|
package com.example.persistence;
import java.util.List;
import javax.inject.Inject;
import org.springframework.stereotype.Repository;
import com.example.domain.Criteria;
@Repository
public class StudentsDAOImpl implements StudentsDAO{
@Inject
SqlSession session;
private static final String namespace="StudentsMapper";
@Override
public List<StudentsVO> list(Criteria cri) throws Exception {
return session.selectList(namespace+".list", cri);
}
@Override
public int total() throws Exception {
return session.selectOne(namespace+".total");
}
@Override
public void insert(StudentsVO vo) throws Exception {
}
@Override
public StudentsVO read(String scode) throws Exception {
return session.selectOne(namespace+".read",scode);
}
@Override
public void update(StudentsVO vo) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void delete(String scode) throws Exception {
// TODO Auto-generated method stub
}
}
|
<com.example.controller>-<StudentsController.java>
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
|
package com.example.web;
import java.text.SimpleDateFormat;
import java.util.Date;
import javax.inject.Inject;
import org.springframework.stereotype.Controller;
import com.example.domain.Criteria;
import com.example.persistence.ProfessorsDAO;
import com.example.persistence.StudentsDAO;
@Controller
@RequestMapping("/students/*")
public class StudentsController {
@Inject
StudentsDAO dao;
@RequestMapping("list")
public String list(Model model, Criteria cri) throws Exception{
model.addAttribute("list", dao.list(cri));
PageMaker pm=new PageMaker();
pm.setTotalCount(dao.total());
model.addAttribute("pm",pm);
return "/students/list";
}
@RequestMapping("insert")
public String insert(){
return "/students/insert";
}
public String insert(StudentsVO vo,String yy,String mm,String dd) throws Exception{
String birthday=yy +"/"+ mm+"/"+dd;
SimpleDateFormat sdf=new SimpleDateFormat("yyyy/MM/dd");
Date date=sdf.parse(birthday);
vo.setBirthday(date);
System.out.println(vo.toString());
return "redirect:/students/list";
}
@RequestMapping("read")
public String read(String scode, Model model) throws Exception{
model.addAttribute("vo", dao.read(scode));
return "/students/read";
}
public String update(StudentsVO vo) throws Exception{
System.out.println(vo.toString());
return "redirect:/students/list";
}
public String delete(String scode) throws Exception{
return "redirect:/students/list";
}
}
|
<src>-<main>-<webapp>-<WEB-INF>-<views>-<students>-<list.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 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>학생목록</title>
<style>
a {text-decoration:none; color:skyblue;}
.active{color:orange;}
</style>
</head>
<body>
<h1>[학생목록]</h1>
데이터:<b>${pm.totalCount}<b>건
<table border=1 width=800>
<tr>
<th width=50>학생번호</th>
<th width=100>학생이름</th>
<th width=100>학생학과</th>
<th width=100>생년월일</th>
<th widtn=200>담당교수</th>
<th width=75>학년</th>
<th width=50>수정</th>
<th width=75>수강신청</th>
</tr>
<c:forEach items="${list}" var="vo">
<tr>
<td><f:formatDate value="${vo.birthday}" pattern="yyyy-MM-dd"/></td>
</tr>
</c:forEach>
</table>
<div id="pagination">
<a href="list?page=${pm.startPage-1}">◀</a>
</c:if>
<c:forEach begin="${pm.startPage}" end="${pm.endPage}" var="i">
[<a class="active" href="list?page=${i}">${i}</a>]
</c:if>
[<a href="list?page=${i}">${i}</a>]
</c:if>
</c:forEach>
<a href="list?page=${pm.endPage+1}">▶</a>
</c:if>
</div>
</body>
</html>
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<src>-<main>-<webapp>-<WEB-INF>-<views>-<students>-<insert.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
|
<%@ 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>학생등록</title>
</head>
<body>
<h1>[학생등록]</h1>
<form action="insert" method="post">
<table border=1 width=700>
<tr>
<td>학생번호</td>
<td><input type="text" name="scode"></td>
</tr>
<tr>
<td>학생이름</td>
<td><input type="text" name="sname"></td>
</tr>
<tr>
<td>학생학과</td>
<td>
<select name="dept">
<option>전산</option>
<option>건축</option>
<option>전자</option>
</select>
</td>
</tr>
<tr>
<td>학년</td>
<td>
<input name ="year" type="radio" value="1" checked>1
<input name ="year" type="radio" value="2">2
<input name ="year" type="radio" value="3">3
<input name ="year" type="radio" value="4">4
</td>
</tr>
<tr>
<td>생년월일</td>
<td>
<input type="text" name="yy" size=4 value="2000">년
<input type="text" name="mm" size=2>월
<input type="text" name="dd" size=2>일
(입력예시:2000년10월04일)
</td>
</tr>
<tr>
<td>담당교수</td>
<td><input type="text" name="advisor"></td>
</tr>
</table>
<input type="submit" value="저장">
<input type="reset" value="취소">
</form>
</body>
</html>
|
<src>-<main>-<webapp>-<WEB-INF>-<views>-<students>-<read.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
|
<%@ 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>학생현황</title>
</head>
<body>
<h1>[학생현황]</h1>
<form action="frm" method="post">
<table border=1 width=700>
<tr>
<td>학생번호</td>
</tr>
<tr>
<td>학생이름</td>
</tr>
<tr>
<td>학생학과</td>
<td>
<select name="dept">
</select>
</td>
</tr>
<tr>
<td>학년</td>
<td>
</td>
</tr>
<!--
<tr>
<td>생년월일</td>
<td>
<input type="text" name="yy" size=4 value="${vo.birthday}">년
<input type="text" name="mm" size=2 value="${vo.birthday}">월
<input type="text" name="dd" size=2 value="${vo.birthday}">일
(입력예시:2000년10월04일)
</td>
</tr>
-->
</table>
<input type="button" value="수정" onClick="funUpdate()">
<input type="reset" value="취소">
<input type="button" value="삭제" onClick="funDelete()">
</form>
</body>
<script>
function funUpdate(){
alert(scode +"-"+ sname +"-"+ dept +"-"+ year);
/*
if(!confirm("수정하시겠습니까?")) return;
frm.action="update";
*/
}
function funDelete(){
if(!confirm("삭제하시겠습니까?")) return;
frm.acttion="delete";
}
</script>
</html>
|
<수강신청 프로그램>
<com.example.domain>-<EnrollVO.java>
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
|
package com.example.domain;
import java.util.Date;
import com.fasterxml.jackson.annotation.JsonFormat;
public class EnrollVO {
private String lcode;
private String lname;
@JsonFormat(pattern="yyyy-MM-dd")
private Date edate;
private String scode;
private int grade;
private String sname;
public String getLcode() {
return lcode;
}
public void setLcode(String lcode) {
this.lcode = lcode;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public Date getEdate() {
return edate;
}
public void setEdate(Date edate) {
this.edate = edate;
}
public String getScode() {
return scode;
}
public void setScode(String scode) {
this.scode = scode;
}
public int getGrade() {
return grade;
}
public void setGrade(int grade) {
this.grade = grade;
}
public String getSname() {
return sname;
}
public void setSname(String sname) {
this.sname = sname;
}
@Override
public String toString() {
return "EnrollVO [lcode=" + lcode + ", lname=" + lname + ", edate=" + edate + ", scode=" + scode + ", grade="
+ grade + ", sname=" + sname + "]";
}
}
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<com.example.persistence>-<EnrollDAO.Interface>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
package com.example.persistence;
import java.util.List;
import com.example.domain.EnrollVO;
public interface EnrollDAO {
public List<EnrollVO> slist(String scode) throws Exception;
public void delete(String scode,String lcode) throws Exception;
public void insert(EnrollVO vo) throws Exception;
public List<EnrollVO> clist(String lcode) throws Exception;
public void update(EnrollVO vo) throws Exception;
}
|
<com.example.persistence>-<EnrollDAOImpl.java>
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
|
package com.example.persistence;
import java.util.HashMap;
import java.util.List;
import javax.inject.Inject;
import org.springframework.stereotype.Repository;
import com.example.domain.EnrollVO;
@Repository
public class EnrollDAOImpl implements EnrollDAO{
@Inject
SqlSession session;
private static final String namespace="EnrollmentsMapper";
@Override
public List<EnrollVO> slist(String scode) throws Exception {
// TODO Auto-generated method stub
return session.selectList(namespace +".slist",scode);
}
@Override
public void delete(String scode, String lcode) throws Exception {
// TODO Auto-generated method stub
HashMap<String, Object> map=new HashMap<String, Object>();
map.put("scode", scode);
map.put("lcode", lcode);
}
@Override
public void insert(EnrollVO vo) throws Exception {
// TODO Auto-generated method stub
}
@Override
public List<EnrollVO> clist(String lcode) throws Exception {
// TODO Auto-generated method stub
return session.selectList(namespace+".clist",lcode);
}
@Override
public void update(EnrollVO vo) throws Exception {
// TODO Auto-generated method stub
}
}
|
<com.example.web>-<EnrollController.java>
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
|
package com.example.web;
import java.util.List;
import javax.inject.Inject;
import org.springframework.stereotype.Controller;
import com.example.domain.EnrollVO;
import com.example.persistence.CoursesDAO;
import com.example.persistence.EnrollDAO;
import com.example.persistence.StudentsDAO;
@Controller
@RequestMapping("/enrollments/*")
public class EnrollController {
@Inject
StudentsDAO sdao;
@Inject
CoursesDAO cdao;
@Inject
EnrollDAO edao;
@RequestMapping("enroll")
public String enroll(String scode,Model model) throws Exception{
model.addAttribute("svo",sdao.read(scode));
model.addAttribute("clist",cdao.list());
return "/enrollments/enroll";
}
@ResponseBody
@RequestMapping("slist.json")
public List<EnrollVO> slist(String scode) throws Exception{
return edao.slist(scode);
}
@ResponseBody
public void delete(String scode,String lcode) throws Exception{
}
@ResponseBody
public String insert(EnrollVO vo) {
String result="";
try{
result="SUCCESS";
}catch(Exception e){
result="FAIL";
}
return result;
}
@RequestMapping("grade")
public String grade(CoursesVO vo,Model model){
model.addAttribute("cvo",vo);
return "/enrollments/grade";
}
@ResponseBody
@RequestMapping("clist.json")
public List<EnrollVO> clist(String lcode) throws Exception{
return edao.clist(lcode);
}
@ResponseBody
@RequestMapping("update")
public void update(EnrollVO vo) throws Exception{
}
}
|
<src/resource/java>-<mappers>-<EnrollmentsMapper.xml>
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
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
<mapper namespace="EnrollmentsMapper">
select e.lcode,c.lname,e.edate
from courses c,enrollments e
where e.scode=#{scode} and e.lcode=c.lcode
</select>
<delete id="delete">
delete from enrollments
where scode=#{scode} and lcode=#{lcode}
</delete>
<insert id="insert">
insert into
enrollments(lcode,edate,scode,grade)
values(#{lcode},now(),#{scode},0)
</insert>
select e.scode,s.sname,e.grade from students s,enrollments e
where e.lcode=#{lcode} and e.scode=s.scode
</select>
<update id="update">
update enrollments
set grade=#{grade}
where lcode=#{lcode} and scode=#{scode}
</update>
</mapper>
|
<src>-<main>-<webapp>-<WEB-INF>-<views>-<enrollments>-<enroll.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
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
127
|
<%@ 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>수강신청 목록</title>
<style>
.title{
background:skyblue; color:gray;
}
.row{
color:gray;
}
.middle{
background:skyblue;
color:gray;
width:580px;
margin-top:10px;
padding:10px;
}
.in,.out{
color:gray;
}
</style>
</head>
<body>
<h1>[수강신청 목록]</h1>
<table border=1 width=600>
<tr >
<th width=100 class="title">학번</th>
<th width=100 class="title">이름</th>
<th width=100 class="title">학과</th>
</tr>
</table>
<div class="middle">
강좌명:
<select id="lcode" class="out">
<c:forEach items="${clist}" var="cvo">
</c:forEach>
</select>
<button id="funInsert">수강신청</button>
</div>
<h1>[학생이 수강신청한 목록]</h1>
<table border=1 width=600 id="tbl"></table>
<script id="temp" type="text/x-handlebars-template">
<tr class="title">
<td>강자코드</td>
<td>강자이름</td>
<td>수강신청일</td>
<td>삭제</td>
</tr>
{{#each .}}
<tr class="row">
<td>{{lcode}}</td>
<td>{{lname}}</td>
<td>{{edate}}</td>
<td><button lcode="{{lcode}}">삭제</button></td>
</tr>
{{/each}}
</script>
</body>
<script>
getList();
$("#funInsert").on("click",function(){
//alert("수강신청 입력");
var lcode=$("#lcode option:selected").val();
//alert(lcode+"-"+scode);
$.ajax({
type:"post",
url:"insert",
data:{"lcode":lcode,"scode":scode},
success:function(result){
if(result=="SUCCESS"){
getList();
}else{
alert("이미 입력되었습니다.");
}
}
});
});
$("#tbl").on("click",".row button", function(){
if(!confirm("삭제하시겠습니까?"))return;
var lcode=$(this).attr("lcode");
//alert(scode +"-"+lcode);
$.ajax({
type:"post",
url:"delete",
data:{"scode":scode,"lcode":lcode},
success:function(){
alert("삭제되었습니다.");
getList();
}
});
});
function getList(){
$.ajax({
type:"get",
url:"slist.json",
data:{"scode":scode},
dataType:"json",
success:function(data){
var temp=Handlebars.compile($("#temp").html());
$("#tbl").html(temp(data));
}
});
}
</script>
</html>
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<src>-<main>-<webapp>-<WEB-INF>-<views>-<enrollments>-<grade.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
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
127
|
<%@ 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>수강신청 목록</title>
<style>
.title{
background:skyblue; color:gray;
}
.row{
color:gray;
}
.middle{
background:skyblue;
color:gray;
width:580px;
margin-top:10px;
padding:10px;
}
.in,.out{
color:gray;
}
</style>
</head>
<body>
<h1>[수강신청 목록]</h1>
<table border=1 width=600>
<tr >
<th width=100 class="title">학번</th>
<th width=100 class="title">이름</th>
<th width=100 class="title">학과</th>
</tr>
</table>
<div class="middle">
강좌명:
<select id="lcode" class="out">
<c:forEach items="${clist}" var="cvo">
</c:forEach>
</select>
<button id="funInsert">수강신청</button>
</div>
<h1>[학생이 수강신청한 목록]</h1>
<table border=1 width=600 id="tbl"></table>
<script id="temp" type="text/x-handlebars-template">
<tr class="title">
<td>강자코드</td>
<td>강자이름</td>
<td>수강신청일</td>
<td>삭제</td>
</tr>
{{#each .}}
<tr class="row">
<td>{{lcode}}</td>
<td>{{lname}}</td>
<td>{{edate}}</td>
<td><button lcode="{{lcode}}">삭제</button></td>
</tr>
{{/each}}
</script>
</body>
<script>
getList();
$("#funInsert").on("click",function(){
//alert("수강신청 입력");
var lcode=$("#lcode option:selected").val();
//alert(lcode+"-"+scode);
$.ajax({
type:"post",
url:"insert",
data:{"lcode":lcode,"scode":scode},
success:function(result){
if(result=="SUCCESS"){
getList();
}else{
alert("이미 입력되었습니다.");
}
}
});
});
$("#tbl").on("click",".row button", function(){
if(!confirm("삭제하시겠습니까?"))return;
var lcode=$(this).attr("lcode");
//alert(scode +"-"+lcode);
$.ajax({
type:"post",
url:"delete",
data:{"scode":scode,"lcode":lcode},
success:function(){
alert("삭제되었습니다.");
getList();
}
});
});
function getList(){
$.ajax({
type:"get",
url:"slist.json",
data:{"scode":scode},
dataType:"json",
success:function(data){
var temp=Handlebars.compile($("#temp").html());
$("#tbl").html(temp(data));
}
});
}
</script>
</html>
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<강좌 프로그램>
<com.example.domain>-<CoursesVO.java>
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
|
package com.example.domain;
public class CoursesVO {
private String lcode;
private String lname;
private String pname;
private String room;
public String getLcode() {
return lcode;
}
public void setLcode(String lcode) {
this.lcode = lcode;
}
public String getLname() {
return lname;
}
public void setLname(String lname) {
this.lname = lname;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public String getRoom() {
return room;
}
public void setRoom(String room) {
this.room = room;
}
@Override
public String toString() {
return "CoursesVO [lcode=" + lcode + ", lname=" + lname + ", pname=" + pname + ", room=" + room + "]";
}
}
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<com.example.persistence>-<CoursesDAO.interface>
1
2
3
4
5
6
7
8
9
10
|
package com.example.persistence;
import java.util.List;
public interface CoursesDAO {
public List<CoursesVO> list() throws Exception;
}
|
<com.example.persistence>-<CoursesDAOImpl.java>
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
|
package com.example.persistence;
import java.util.List;
import javax.inject.Inject;
import org.springframework.stereotype.Repository;
@Repository
public class CoursesDAOImpl implements CoursesDAO{
@Inject
SqlSession session;
private static final String namespace="CoursesMapper";
@Override
public List<CoursesVO> list() throws Exception {
// TODO Auto-generated method stub
return session.selectList(namespace +".list");
}
}
|
<com.example.web>-<CoursesController.java>
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
|
package com.example.web;
import javax.inject.Inject;
import org.springframework.stereotype.Controller;
import com.example.persistence.CoursesDAO;
@Controller
@RequestMapping("/courses/*")
public class CoursesController {
@Inject
CoursesDAO dao;
@RequestMapping("list")
public String list(Model model) throws Exception{
model.addAttribute("list",dao.list());
return "/courses/list";
}
}
|
<src/resource/java>-<mappers>-<CoursesMapper.xml>
1
2
3
4
5
6
7
8
9
10
11
12
|
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE mapper
<mapper namespace="CoursesMapper">
select c.*,pname
from courses c,professors
where pcode=instructor
</select>
</mapper>
|
<src>-<main>-<webapp>-<WEB-INF>-<views>-<courses>-<list.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
|
<%@ 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>강좌목록</title>
</head>
<body>
<h1>[강좌목록]</h1>
<table border=1 width=700>
<tr>
<th>강좌번호</th>
<th>강좌이름</th>
<th>담당교수</th>
<th>강의실</th>
</tr>
<c:forEach items="${list}" var="vo">
<tr>
<td><button onClick="location.href='../enrollments/grade?lcode=${vo.lcode}&lname=${vo.lname}'">성적입력</button></td>
</tr>
</c:forEach>
</table>
</body>
</html>
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
'spring > 소스코드' 카테고리의 다른 글
kakaoAPI를 이용한 책검색-검색개수,마지막페이지 여부 (0) | 2019.10.25 |
---|---|
○네이버 xml,json 이용한 검색프로그램 파일 만들기 (0) | 2019.10.24 |
c라이브러리를 이용한 학사 페이징 작업 (0) | 2019.10.22 |
$.ajax을 이용한 입력,삭제,수정,읽기 프로그램(페이징 프로그램,검색 프로그램) (0) | 2019.10.21 |
페이지 번호로 이동하기 (0) | 2019.10.18 |