티스토리 뷰



이제 디비의 모든 페이지를 다 띄울수있다..!



이제 title을 눌렀을때 readPage로 가게하고 거기서 삭제 , 수정 처리와 다시 원래 페이지로 돌아오게하는 코드를 추가할것이다.


기존 boardController을 수정




 read.jsp를 수정하여 readPage.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
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/header.jsp" %>
 
<script>
 
$(document).ready(function(){
    
    var formObj = $("form[role='form']");
    
    console.log(formObj);
    
    
    $(".btn-warning").on("click"function(){
        formObj.attr("action""/board/modifyPage");
        formObj.attr("method""get");
        formObj.submit();
    });
    $(".btn-dander").on("click"function(){
        formObj.attr("method""post");
        formObj.attr("action""/board/removePage");
        formObj.submit();
    });
    $(".btn-primary").on("click"function(){
        formObj.attr("method""get");
        formObj.attr("action""/board/listPage");
        formObj.submit();
    });
    
})
 
</script>
 
<form role="form" method="post">
    <input type='hidden' name='bno' value="${boardVO.bno }">
</form>
<form role="form" action="modifyPage" method="post">
    <input type='hidden' name='bno' value="${boardVO.bno }">
    <input type='hidden' name='page' value="${cri.page }">
    <input type='hidden' name='perPageNum' value="${cri.perPageNum }">
</form>
 
<div class="box-body">
    <div class="form-group">
        <label for="exampleInputEmail1">Title</label
        <input type="text" name='title' class="form-control" value="${boardVO.title}" readonly='readonly'>
    </div>
    <div class="form-group">
        <label for="exampleInputPassword1">Content</label
        <textarea class="form-control" name="content" rows="3" readonly="readonly">${boardVO.content }</textarea>
    </div>
    <div class="form-group">
        <label for="exampleInputEmail1">Writer</label>
        <input type="text" name="writer" class="form-control" value="${boardVO.writer }" readonly="readonly">
    </div>
</div>
<div class="box-footer">
    <button type="submit" class="btn btn-warning">Modify</button>
    <button type="submit" class="btn btn-dander">Remove</button>
    <button type="submit" class="btn btn-primary">LIST ALL</button>
</div>
 
 
 
 
cs


modifyPage 도 수정하여 아래와 같이 만들었고


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
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c" %>
<%@ page session="false" %>
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8" %>
<%@ include file="../include/header.jsp" %>
 
<script>
    $(document).ready(function() {
        
        var formObj = $("form[role='form']");
        console.log(formObj);
        
        $(".btn-warning").on("click"function(){
            self.location = "/board/listPage?page=${cri.page}&perPageNum=${cri.perPageNum}";
        });
        
        $(".btn-primary").on("click"function(){
            formObj.submit();
        });
        
    });
</script>
 
<form role="form" action="modifyPage" method="post">
    <input type='hidden' name='page' value="${cri.page }">
    <input type='hidden' name='perPageNum' value="${cri.perPageNum }">
        <div class="box-body">
            <div class="form-group">
                <label for="exampleInputEmail1">BNO</label>
                <input type="text" name='bno' class="form-control" 
                        value="${boardVO.bno }" readonly="readonly">
            </div>
            <div class="form-group">
                <label for="exampleInputEmail1">Title</label
                <input type="text" name='title' class="form-control" value="${boardVO.title}">
            </div>
            <div class="form-group">
                <label for="exampleInputPassword1">Content</label
                <textarea class="form-control" name="content" rows="3">${boardVO.content }</textarea>
            </div>
            <div class="form-group">
                <label for="exampleInputEmail1">Writer</label>
                <input type="text" name="writer" class="form-control" value="${boardVO.writer }">
            </div>
        </div>
</form>
        
<div class="box-footer">
    <button type="submit" class="btn btn-primary">SAVE</button>
    <button type="submit" class="btn btn-warning">CANCEL</button>
</div>
cs



boardController는 이런식으로 수정되었다


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
@RequestMapping(value="/readPage", method=RequestMethod.GET)
    public void read(@RequestParam("bno"int bno, 
            @ModelAttribute("cri"
            Criteria cri, 
            Model model) throws Exception{
        model.addAttribute(service.read(bno));
    }
 
    @RequestMapping(value="/removePage", method=RequestMethod.POST)
    public String remove(@RequestParam("bno"int bno,
            Criteria cri, RedirectAttributes rttr) throws Exception{
        service.remove(bno);
        rttr.addAttribute("page", cri.getPage());
        rttr.addAttribute("perPageNum", cri.getPerPageNum());
        rttr.addFlashAttribute("msg""SUCCESS");
        
        return "redirect:/board/listPage";
    }
 
    @RequestMapping(value="/modifyPage", method=RequestMethod.GET)
    public void modifyPagingGET(@RequestParam("bno"int bno,
            @ModelAttribute("cri") Criteria cri,
            Model model) throws Exception{
        model.addAttribute(service.read(bno));
    }
    
    @RequestMapping(value="/modifyPage", method=RequestMethod.POST)
    public String modifyPagingPOST(BoardVO board,
            Criteria cri, RedirectAttributes rttr) throws Exception{
        
        service.modify(board);
        
        rttr.addAttribute("page", cri.getPage());
        rttr.addAttribute("perPageNum", cri.getPerPageNum());
        rttr.addFlashAttribute("msg""SUCCESS");
        
        return "redirect:/board/listPage";
    }
cs



그 결과! 



modify 화면 bno는 수정 불가능하다.




결과 




그리고 remove test로 919항목이 사라전걸 볼 수 있다.







다음은 검색기능을 넣을거다..


슬슬 플젝도 시작해야하는데!

'SPRING' 카테고리의 다른 글

180807 개발일기  (0) 2018.08.07
0806 개발일기 게시판 검색기능  (0) 2018.08.07
0803 개발일기 페이징 Criteria  (0) 2018.08.04
0731 개발일기 익셉션 페이징  (0) 2018.07.31
0730 개발일기  (0) 2018.07.30
댓글
공지사항
최근에 올라온 글
최근에 달린 댓글
Total
Today
Yesterday
링크
«   2024/11   »
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
글 보관함