<com.example.domain>-ProfessorsVO.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
|
package com.example.domain;
import java.util.Date;
public class ProfessorsVO {
private String pcode;
private String pname;
private String dept;
private Date Hiredate;
private int salary;
private String title;
public String getPcode() {
return pcode;
}
public void setPcode(String pcode) {
this.pcode = pcode;
}
public String getPname() {
return pname;
}
public void setPname(String pname) {
this.pname = pname;
}
public String getDept() {
return dept;
}
public void setDept(String dept) {
this.dept = dept;
}
public Date getHiredate() {
return Hiredate;
}
public void setHiredate(Date hiredate) {
Hiredate = hiredate;
}
public int getSalary() {
return salary;
}
public void setSalary(int salary) {
this.salary = salary;
}
public String getTitle() {
return title;
}
public void setTitle(String title) {
this.title = title;
}
@Override
public String toString() {
return "ProfessorsVO [pcode=" + pcode + ", pname=" + pname + ", dept=" + dept + ", Hiredate=" + Hiredate
+ ", salary=" + salary + ", title=" + title + "]";
}
}
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<com.example.domain>-Criteria.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
|
package com.example.domain;
public class Criteria{
private int page;
private int perPageNum;
public Criteria(){
this.page = 1;
this.perPageNum = 3;
}
public void setPage(int page){
if (page <= 0){
this.page = 1;
return;
}
this.page = page;
}
public void setPerPageNum(int perPageNum){
if(perPageNum <= 0 || perPageNum > 100){
this.perPageNum = 10;
return;
}
this.perPageNum = perPageNum;
}
public int getPage(){
return page;
}
public int getPageStart(){
return (this.page - 1) * perPageNum;
}
public int getPerPageNum(){
return this.perPageNum;
}
@Override
public String toString(){
return "Criteria [page=" + page + ", " + "perPageNum=" + perPageNum + "]";
}
}
|
<com.example.domain>-PageMaker.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
|
package com.example.domain;
public class PageMaker{
private int totalCount;
private int startPage;
private int endPage;
private boolean prev;
private boolean next;
private int displayPageNum = 10;
private Criteria cri;
public void setCri(Criteria cri){
this.cri = cri;
}
public void setTotalCount(int totalCount){
this.totalCount = totalCount;
calcData();
}
private void calcData(){
startPage = (endPage - displayPageNum) + 1;
if(endPage > tempEndPage){
endPage = tempEndPage;
}
prev = startPage == 1 ? false : true;
next = endPage * cri.getPerPageNum() >= totalCount ? false : true;
}
public int getStartPage() {
return startPage;
}
public void setStartPage(int startPage) {
this.startPage = startPage;
}
public int getEndPage() {
return endPage;
}
public void setEndPage(int endPage) {
this.endPage = endPage;
}
public boolean isPrev() {
return prev;
}
public void setPrev(boolean prev) {
this.prev = prev;
}
public boolean isNext() {
return next;
}
public void setNext(boolean next) {
this.next = next;
}
public int getDisplayPageNum() {
return displayPageNum;
}
public void setDisplayPageNum(int displayPageNum) {
this.displayPageNum = displayPageNum;
}
public int getTotalCount() {
return totalCount;
}
public Criteria getCri() {
return cri;
}
}
|
<com.example.persistence>-ProfessorsDAO.Interface
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
|
package com.example.persistence;
import java.util.List;
import com.example.domain.Criteria;
public interface ProfessorsDAO {
public List<ProfessorsVO> list(Criteria cri)throws Exception;
public int total()throws Exception;
public void insert(ProfessorsVO vo) throws Exception;
public ProfessorsVO read(String pcode) throws Exception;
public void update(ProfessorsVO vo) throws Exception;
public void delete(String pcode) throws Exception;
}
|
<com.example.persistence>-ProfessorsDAO.Impljava
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
|
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 ProfessorsDAOImpl implements ProfessorsDAO{
@Inject
SqlSession session;
private static final String namespace="ProfessorsMapper";
@Override
public List<ProfessorsVO> 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(ProfessorsVO vo) throws Exception {
}
@Override
public ProfessorsVO read(String pcode) throws Exception {
return session.selectOne(namespace+".read",pcode);
}
@Override
public void update(ProfessorsVO vo) throws Exception {
// TODO Auto-generated method stub
}
@Override
public void delete(String pcode) throws Exception {
// TODO Auto-generated method stub
}
}
|
<com.example.web>-ProfessorsController.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
|
package com.example.web;
import javax.inject.Inject;
import org.springframework.stereotype.Controller;
import com.example.domain.Criteria;
import com.example.persistence.ProfessorsDAO;
@Controller
@RequestMapping("/professors/*")
public class ProfessorsController {
@Inject
ProfessorsDAO dao;
@RequestMapping("list")
public String list(Model model, Criteria cri) throws Exception{
System.out.println(cri.toString());
model.addAttribute("list", dao.list(cri));
PageMaker pm=new PageMaker();
pm.setTotalCount(dao.total());
model.addAttribute("pm",pm);
return "/professors/list";
}
@RequestMapping("insert")
public String insert(){
return "/professors/insert";
}
public String insert(ProfessorsVO vo) throws Exception{
return "redirect:/professors/list";
}
@RequestMapping("read")
public String read(String pcode, Model model) throws Exception{
model.addAttribute("vo", dao.read(pcode));
return "/professors/read";
}
public String update(ProfessorsVO vo) throws Exception{
return "redirect:/professors/list";
}
public String delete(String pcode) throws Exception{
return "redirect:/professors/list";
}
}
|
<src/main/resource>-DBTest.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
|
package com.ICIA.example;
import javax.inject.Inject;
import org.junit.Test;
import org.junit.runner.RunWith;
import com.example.persistence.ProfessorsDAO;
import com.example.persistence.StudentsDAO;
@RunWith(SpringJUnit4ClassRunner.class)
@ContextConfiguration(locations = { "file:src/main/webapp/WEB-INF/spring/**/*.xml" })
public class DBTest {
@Inject
ProfessorsDAO pdao;
StudentsDAO sdao;
@Test
public void plist() throws Exception{
}
@Test
public void sinsert() throws Exception{
StudentsVO vo=new StudentsVO();
}
}
|
<src/resource/test>-<mappers>-ProfessorsMapper.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="ProfessorsMapper">
select * from professors
limit #{pageStart}, #{perPageNum}
</select>
<select id="total" resultType="int">
select count(*) from professors
</select>
<insert id="insert">
insert into professors(pcode, pname, dept, title, salary, hiredate)
values(#{pcode},#{pname},#{dept},#{title},#{salary},now())
</insert>
select * from professors where pcode=#{pcode}
</select>
<update id="update">
update professors
set pname=#{pname},dept=#{dept},title=#{title},salary=#{salary}
where pcode=#{pcode}
</update>
<delete id="delete">
delete from professors
where pcode=#{pcode}
</delete>
</mapper>
|
<src>-<main>-<webapp>-<WEB-INF>-<spring>-<view>-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
|
<%@ 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=700>
<tr>
<th width=100>교수번호</th>
<th width=100>교수이름</th>
<th width=100>교수학과</th>
<th width=100>교수직급</th>
<th width=100>교수급여</th>
<th width=100>임용일자</th>
<th width=100>수정</th>
</tr>
<c:forEach items="${list}" var="vo">
<tr>
<td><f:formatDate value="${vo.hiredate}" 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>
|
<src>-<main>-<webapp>-<WEB-INF>-<spring>-<view>-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
|
<%@ 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="pcode"></td>
</tr>
<tr>
<td>교수이름</td>
<td><input type="text" name="pname"></td>
</tr>
<tr>
<td>교수학과</td>
<td>
<select name="dept">
<option>전산</option>
<option>건축</option>
<option>전자</option>
</select>
</td>
</tr>
<tr>
<td>교수직급</td>
<td>
<input type="radio" name="title" value="정교수">정교수
<input type="radio" name="title" value="부교수">부교수
<input type="radio" name="title" value="조교수">조교수
</td>
</tr>
<tr>
<td>교수급여</td>
<td><input type="text" name="salary"></td>
</tr>
</table>
<input type="submit" value="저장" >
<input type="reset" value="취소">
</form>
</body>
</html>
http://colorscripter.com/info#e" target="_blank" style="color:#e5e5e5text-decoration:none">Colored by Color Scripter
|
http://colorscripter.com/info#e" target="_blank" style="text-decoration:none;color:white">cs |
<src>-<main>-<webapp>-<WEB-INF>-<spring>-<view>-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
|
<%@ 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 name="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>
</tr>
</table>
<input type="button" value="저장" onClick="funupdate()">
<input type="button" value="삭제" onClick="fundelete()">
<input type="reset" value="취소">
</form>
</body>
<script>
function funupdate(){
if(!confirm("수정하시겠습니까?")) return;
}
function fundelete(){
if(!confirm("삭제하시겠습니까?")) return;
}
</script>
</html>
|
'spring > 소스코드' 카테고리의 다른 글
kakaoAPI를 이용한 책검색-검색개수,마지막페이지 여부 (0) | 2019.10.25 |
---|---|
○네이버 xml,json 이용한 검색프로그램 파일 만들기 (0) | 2019.10.24 |
학사 프로그램 만들기 (0) | 2019.10.23 |
$.ajax을 이용한 입력,삭제,수정,읽기 프로그램(페이징 프로그램,검색 프로그램) (0) | 2019.10.21 |
페이지 번호로 이동하기 (0) | 2019.10.18 |