본문 바로가기
매일코딩/Spring

28.spring - hitup

by 인생여희 2016. 11. 18.
반응형

1.controller


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
    @RequestMapping("board/view.do")
    public String view(@RequestParam int idx, Model model) throws Exception {
 
        
        
        boardService.hitUp(idx);
 
        BoardDTO dto = boardService.boardView(idx);
 
        model.addAttribute("dto", dto);
 
        return "board/view";
    }
    
    
    
    
cs




2.service,  dao


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
@Override
    public BoardDTO boardView(int idx) {
 
        System.out.println("check dao");
 
        BoardDTO dto = null;
 
        try {
            dto = sqlSession.selectOne("boardView", idx);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        return dto;
    }
 
    @Override
    public void hitUp(int idx) {
 
        try {
            sqlSession.update("hitUp", idx);
        } catch (Exception e) {
 
            e.printStackTrace();
        }
 
    }
    
    
cs


3.mapper


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
<update id="hitUp">
 
        update board set hit=hit+where idx=#{idx}
    </update>
 
 
 
    <select id="boardView" resultType="boardDto">
 
        select * from board
        where idx =
        #{idx}
    </select>
 
    
    
    
    
    
cs


4. view.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
128
129
130
131
132
 
    <%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<%-- <%@ page session="false"%> --%>
<c:set var="path" value="${pageContext.request.contextPath}"></c:set> 
 
 
<jsp:include page="boardHeader.jsp" flush="false"/>
 
 
                    <h1 id="product"><div>COMMUNITY</div></h1>
          <article>
              <h2>게시판</h2>
              
    <!-- 개발 경로가 아닌 실제 경로 -->
    <%-- <%=application.getRealPath("/upload")%> --%>
 
 
    <form name="form1" method="post" enctype="multipart/form-data">
        <table border="1" width="650px" align="center" >
 
 
 
            <tr>
                <td align="center">날짜</td>
                <td align="center">${dto.post_date}</td>
                <td align="center">조회수</td>
                <td align="center">${dto.hit}</td>
            </tr>
 
            <tr>
                <td align="center">제목</td>
                <td colspan="3"><input name="subject" size="80"
                    value="${dto.subject}"></td>
            </tr>
            <tr>
                <td align="center">내용</td>
                <td colspan="3"><textarea rows="5" cols="80" name="content"
                        id="content">${dto.content}</textarea>
                        
                        
                         <script>
                            //textarea의 id값과 일치해야함//textarea의 id값과 일치해야함
                            CKEDITOR
                                    .replace(
                                            'content',
                                            {
                                                filebrowserUploadUrl : '${pageContext.request.contextPath}/imageUpload.do'
 
                                            });
                        </script>
                        
                        
                        </td>
            <tr>
                <td align="center">첨부파일</td>
                <td colspan="3" width='30'>
                <c:if test="${dto.filesize>0 }">
                ${dto.filename} (${dto.filesize} bytes)
                <br>
                
                <input type="checkbox" name="fileDel">첨부파일 삭제
                
                </c:if>
                
                <input type="file" name="file1"></td>
 
            </tr>
 
 
 
 
            <tr>
                <td colspan="4" align="center">
                
                
                <!-- 로그인 했을때 답변달 수있게 했음 -->    
                <c:if test="${sessionScope.id != null}">
                <input type="button" value="답변" id="btnReply">
                </c:if>
            
            
                 <!-- 본인글만 수정/삭제가 가능하도록 처리 -->
                <c:if test="${sessionScope.id==dto.userid }">
                        <input type="button" value="수정" id="btnUpdate">
                        <input type="button" value="삭제" id="btnDelete">
                        <input type="button" value="목록" id="btnList">
                </c:if>
            
            
                </td>
            
            
            </tr>
        </table>
    </form>
 
 
 <!-- 답변글 작성을 위해 게시물 번호를 넘겨야함 -->
<input type="hidden" name="idx" id="idx" value="${dto.idx}">
 
    <!-- 댓글 작성폼(로그인한 사용자만 댓글 달기 허용) -->
 
 
    <div align="center" >
        <c:if test="${sessionScope.id != null }">
 
            <table style="width: 650px;" class="tbl_type">
                
<br>
                <font size="4" style="text-decoration : underline ;"><B>댓글달기</B></font>
                
      
        <br>
                
                <tr>
                <br>
                    <td ><textarea rows="3" cols="81" id="comment_content"></textarea></td>
                    <td><input type="button" style="width:40pt;height:40pt;" value="댓글" id="btnSave"></td>
                </tr>
            </table>
        </c:if>
    </div>
 
    <div id="commentList" align="center"></div>
 
 
    </article>
          <jsp:include page="boardSidebar.jsp" flush="false"/>
 
          <jsp:include page="boardFooter.jsp" flush="false"/>
cs


반응형

'매일코딩 > Spring' 카테고리의 다른 글

30.스프링프로젝트 - 답변  (4) 2016.11.21
29.spring- detgul  (2) 2016.11.18
27.springproject - log  (4) 2016.11.18
26.스프링프로젝트 - 페이징 처리  (6) 2016.11.17
25.스프링프로젝트 - aop  (6) 2016.11.17

댓글