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

29.spring- detgul

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

* 컨트롤러를 @RestController로 선언

* 컨트롤러의 method를 @ResponseBody 로 선언

@RestController  // 스프링 4.0 이후 사용 가능

public class FileController {

@Inject

BoardDao boardDao;

@ResponseBody

@RequestMapping("board/board_ajax_list.do")

public  List boardList(){

List<BoardDto> list=boardDao.getBoardList(1,10);

return list;

}

}

* pom.xml에 라이브러리 추가

<!-- json 라이브러리 -->

<dependency>

    <groupId>com.fasterxml.jackson.core</groupId>

    <artifactId>jackson-databind</artifactId>

    <version>2.5.0</version>

</dependency>


CONTENT FROM:http://edu.lifesoft.org/board/show.aspx?category=spring&idx=375&page=0


0.view header.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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
   <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core"%>
 
<c:set var="path" value="${pageContext.request.contextPath}"></c:set> 
    
<html>
<head>
<meta charset="utf-8">
<title>Company</title>
 
<link href="../resources/css/reset.css" rel="stylesheet" type="text/css">
 
<link href="../resources/css/jquery.fancybox.css" rel="stylesheet" type="text/css">
 
 
<link href='http://fonts.googleapis.com/css?family=Droid+Sans'
    rel='stylesheet' type='text/css'>
    
    
    <style>
/* UI Object */
.tbl_type,.tbl_type th,.tbl_type td{border:0}
.tbl_type{width:75%;border-bottom:2px solid #dcdcdc;font-family:'돋움',dotum;font-size:12px;text-align:center;border-collapse:collapse}
.tbl_type caption{display:none}
.tbl_type tfoot{background-color:#f5f7f9;font-weight:bold}
.tbl_type th{padding:7px 4px;border-top:2px solid #dcdcdc;border-right:1px solid #dcdcdc;border-left:1px solid #dcdcdc;background-color:#f5f7f9;color:#666;font-family:'돋움',dotum;font-size:12px;font-weight:bold}
.tbl_type td{padding:6px 4px;border:1px solid #e5e5e5;color:#4c4c4c}
.tbl_type td.ranking{font-weight:bold}
/* //UI Object */
</style>
    
    <script src="http://code.jquery.com/jquery-1.12.4.js"></script>
    <script type="text/javascript">
    $(document).ready(
            function() { //웹페이지가 로딩되면
 
                comment_list('1'); //댓글 목록 가져오기
 
                //수정 버튼 클릭
                
                 $("#btnUpdate").click(function(){
                     
                     document.form1.action="${path}/board/board_update.do?idx="+$("#idx").val();
                         
                         /* ?idx="+$("#idx").val()
                             +"?subject="+$("#subject").val()+"?filename="+$("#filename").val()
                             +"?filesize="+$("#filesize").val()+"?content="+$(content).val(); */
                     document.form1.submit();
                 })
                
                
                
                 //글쓰기 버튼 클릭
                $("#btnWrite").click(function(){
                    location.href="${path}/board/write.do";
                });
                 
                 
                //목록 버튼 클릭
                $("#btnList").click(function(){
                    location.href="${path}/board/board_list.do";
                });
 
                //답변 버튼 클릭
                
                $("#btnReply").click(function(){
                
                    document.form1.action="${path}/board/board_reply.do?idx="+$("#idx").val();
                    document.form1.submit();
                });
                
                //삭제 버튼 클릭
                
                $("#btnDelete").click(function(){
                    
                    if(confirm("삭제하시겠습니까?")){
                        document.form1.action ="${path}/board/board_delete.do?idx="+$("#idx").val();
                        document.form1.submit();
                    }
                
                });
                
                
                
                
                
                $("#btnSave").click(
                        function() {//버튼 클릭 이벤트 등록
 
                            var param = "board_idx=${dto.idx}&content="
                                    + $("#comment_content").val();
                            //비동기 방식으로 댓글 쓰기, 결과값은 json 형식으로 리턴받음
 
                            $.ajax({
                                type : "post",
                                
                                /*  if this is empty..defalut type is html */
                                contentType : "application/json",
                                url : "${path}/board/comment_insert.do?"+param,
                                success : function() {
                                    
                                    //댓글쓰기가 완료되면 댓글 목록 갱신
                                    comment_list('1');
                                    
                                    //댓글 입력 텍스트상자 초기화
                                    $("#comment_content").val("");
                                }
 
                            });
 
                        });
            });
 
    //댓글 목록 가져오기
    function comment_list(page) {
 
        $.ajax({
            type : "post",
            contentType : "application/json",
            url : "${path}/board/comment_list.do?board_idx=${dto.idx}&curPage="+page,
            success : function(data) {
 
                /* var output = "<table width='800px' border='1'>";
                for ( var i in json) {
                    output += "<tr>";
                    output += "<td>" + json[i].post_date + "</td>";
                    output += "<td>" + json[i].content + "</td>";
                    output += "</tr>";
                }
                output += "</table>"; */
 
                $("#commentList").html(data);
            }
 
        });
 
    }
</script>
 
<script type="text/javascript" src="${path}/ckeditor/ckeditor.js"></script>
    
</head>
 
 
 
 
<body>
        <div id="wrap">
            
            <!-- 헤더부분 -->
            
            <header>
                <div id="logo"><a href="${pageContext.request.contextPath}/main/main.html">YNG Corp.</a> </div>
                <div id="hlink">
                    <ul>
                                    <c:choose>
                        <c:when test="${sessionScope.id==null }">
                            <!-- 세션변수 id 값이 없을때 -->
                            <li><a href="${path}/member/login">로그인·회원가입</a></li>
                        <!--     <li><a href="/web03/member/memberInsert">회원가입</a></li> -->
                        </c:when>
 
                        <c:otherwise>
                            <!-- 세션 변수 id 값이 있을때 -->
        
    [  ${sessionScope.name}님 로그인 중 ]
    <li><a href="${path}/member/logout">로그아웃</a></li>
    
                            <%-- <a href="${path}/pdf/pdf_save.do">pdf문서생성</a>
                            <a href="${path}/chart/chart1.do">차트보기</a> --%>
                            <%-- <li><a href="${path}/member/member_info.do">회원정보 수정</a></li> --%>
                        </c:otherwise>
 
                    </c:choose>
                    
                    </ul>
                </div>
                
                <nav>
                    <ul>
                        <li class="n1"><a href="${pageContext.request.contextPath}/company/company.html">회사소개</a></li>                    
                        <li class="n2"><a href="${pageContext.request.contextPath}/product/product.html">제품정보</a></li>
                        <li class="n3"><a href="${pageContext.request.contextPath}/board/board_list.do">커뮤니티</a></li>
                        <li class="n4"><a href="${pageContext.request.contextPath}/mail/mail_form.do">고객지원</a></li>
                    </ul>
                </nav>
            </header>    
cs



1.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
133
<%@ 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" >
    
        <!-- if user is not null  only login-->
        <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


2.commentDTO


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
package com.example.web03.model.board.dto;
 
import java.sql.Date;
 
public class CommentDTO {
 
    
    private int comment_idx;
    private int board_idx;
    private String userid;
    private String username;
    private String content;
    
    public String getUsername() {
        return username;
    }
    public void setUsername(String username) {
        this.username = username;
    }
    private Date post_date;
    public int getComment_idx() {
        return comment_idx;
    }
    public void setComment_idx(int comment_idx) {
        this.comment_idx = comment_idx;
    }
    public int getBoard_idx() {
        return board_idx;
    }
    public void setBoard_idx(int board_idx) {
        this.board_idx = board_idx;
    }
    public String getUserid() {
        return userid;
    }
    public void setUserid(String userid) {
        this.userid = userid;
    }
    public String getContent() {
        return content;
    }
    public void setContent(String content) {
        this.content = content;
    }
    public Date getPost_date() {
        return post_date;
    }
    public void setPost_date(Date post_date) {
        this.post_date = post_date;
    }
    @Override
    public String toString() {
        return "CommentDTO [comment_idx=" + comment_idx + ", board_idx=" + board_idx + ", userid=" + userid
                + ", content=" + content + ", post_date=" + post_date + "]";
    }
    
    
    
    
}
 
cs





3.COMMENTCONTROOLER


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.web03.controller.board;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.inject.Inject;
import javax.servlet.http.HttpSession;
 
import org.springframework.ui.Model;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestParam;
import org.springframework.web.bind.annotation.ResponseBody;
import org.springframework.web.bind.annotation.RestController;
import org.springframework.web.servlet.ModelAndView;
 
import com.example.web03.model.board.dao.PageDAO;
import com.example.web03.model.board.dto.CommentDTO;
import com.example.web03.service.board.BoardService;
 
//RestController : ajax 처리 전용 컨트롤러 (백그라운드에서 실행되는 컨트롤러)
 
@RestController // 스프링 4.0이상 부터 가능
public class CommentController {
 
    @Inject
    BoardService boardService;
 
    // 댓글목록을 리턴
    @ResponseBody // 리턴자료형을 json으로 변환
    @RequestMapping("board/comment_list.do")
    public ModelAndView comment_list(
            @RequestParam(defaultValue="1"int curPage,
            @RequestParam int board_idx, Model model) {
        
        //댓글 갯수 개산
        int count =boardService.commentCount(board_idx);
        
        //페이지 나누기 관련 클래스
        PageDAO pageDao=new PageDAO(count,curPage);
                int start=pageDao.getPageBegin();
                int end=pageDao.getPageEnd();
        
                
                
        // 게시물 번호가 board_idx 변수에 저장됨
        List<CommentDTO> list = boardService.commentList(board_idx,start,end);
 
        Map<String,Object> map=new HashMap<String,Object>();
        map.put("list", list);    //맵에 리스트 추가
        map.put("page", pageDao);    // 맵에 페이지 정보 추가
        
        //board/comment_list.jsp 로 포워딩
        ModelAndView mav=new ModelAndView("board/comment_list","map",map);
    
        // new ModelAndView("포워딩할 jsp 페이지",모델변수명, 모델변수 값);
        // 뷰로 포워딩되지 않고 데이터만 ajax를 호출한 페이지로 넘김(json포멧)
        return mav;
    }
 
    @RequestMapping("board/comment_insert.do")
    public void comment_insert(@RequestParam int board_idx, @RequestParam String content, HttpSession session) {
 
        String id=(String)session.getAttribute("id");
        
        CommentDTO dto=new CommentDTO();
        dto.setUserid(id);
        dto.setBoard_idx(board_idx);
        dto.setContent(content);
        
        boardService.commentInsert(dto);
    }
 
}
 
cs



COMMENTDAO

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
package com.example.web03.model.board.dao;
 
import java.util.HashMap;
import java.util.List;
import java.util.Map;
 
import javax.inject.Inject;
 
import org.apache.ibatis.session.SqlSession;
import org.springframework.stereotype.Repository;
 
import com.example.web03.model.board.dto.CommentDTO;
 
@Repository // 스프링에서 관리하는 dao bean
public class CommentDAOImpl implements CommentDAO {
 
    // 주입
    @Inject
    SqlSession sqlSession;
 
    @Override
    public List<CommentDTO> commentList(int board_idx,int start,int end) {
 
        List<CommentDTO> list = null;
 
        
        Map<String,Object> map=new HashMap<String,Object>();
        
        map.put("board_idx", board_idx);
        map.put("start", start);
        map.put("end", end);
        
        try {
 
            list = sqlSession.selectList("commentList", map);
 
        } catch (Exception e) {
            e.printStackTrace();
        }
 
        return list;
    }
 
    @Override
    public void commentInsert(CommentDTO dto) {
 
        try {
            sqlSession.insert("commentInsert", dto);
        } catch (Exception e) {
            e.printStackTrace();
        }
 
    }
 
    @Override
    public int commentCount(int board_idx) {
 
        int count = 0;
 
        try {
            count = sqlSession.selectOne("commentCount", board_idx);
        } catch (Exception e) {
        }
 
        return count;
    }
 
}
 
cs


BOARDSERVICE

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
133
134
135
136
137
138
139
140
package com.example.web03.service.board;
 
import java.io.File;
import java.util.List;
 
import javax.inject.Inject;
 
import org.springframework.stereotype.Service;
 
import com.example.web03.model.board.dao.BoardDAO;
import com.example.web03.model.board.dao.CommentDAO;
import com.example.web03.model.board.dto.BoardDTO;
import com.example.web03.model.board.dto.CommentDTO;
 
@Service // �쁽�옱 �겢�옒�뒪瑜� �뒪�봽留� �꽌鍮꾩뒪 鍮덉쑝濡� �벑濡앹떆�궡
public class BoardServiceImpl implements BoardService {
 
    @Inject
    BoardDAO boardDAO; // BoardDAOImpl �씤�뒪�꽩�뒪瑜� �깮�꽦�븯�뿬 二쇱엯�떆�궡
 
    @Inject
    CommentDAO commentDao;
    
    @Override
    public List<BoardDTO> boardList(int start, int end,String search_option, String search) {
 
        List<BoardDTO> list;
 
        list = boardDAO.boardList(start, end,search_option,search);
 
        return list;
    }
 
    // 湲��벐湲�+ �뙆�씪�뾽濡쒕뱶
    @Override
    public void boardInsert(BoardDTO dto) {
        boardDAO.boardInsert(dto);
 
    }
 
    // �뙆�씪�씠由� �뼸湲�
    @Override
    public String getFilename(int idx) {
        return boardDAO.getFilename(idx);
    }
 
    // �떎�슫濡쒕뱶 �슏�닔 利앷�
    @Override
    public void downUp(int idx) {
 
        boardDAO.downUp(idx);
 
    }
    //珥앷컻�떆臾쇱닔 援ы븯湲�
    @Override
    public int boardCount(String search_option, String search) {
 
        return boardDAO.boardCount(search_option,search);
    }
 
    
    
    @Override
    public BoardDTO boardView(int idx) {
        System.out.println("check service");
        
        return boardDAO.boardView(idx);
    }
 
    @Override
    public void hitUp(int id) {
        
        boardDAO.hitUp(id);
        
    }
 
    @Override
    public List<CommentDTO> commentList(int board_idx,int start,int end) {
        
        return commentDao.commentList(board_idx,start,end);
    }
 
    @Override
    public void commentInsert(CommentDTO dto) {
        
        commentDao.commentInsert(dto);
    }
 
    @Override
    public int commentCount(int board_idx) {
        
        return commentDao.commentCount(board_idx);
    }
 
    @Override
    public void reorderUpdate(int ref, int reorder) {
        boardDAO.reorderUpdate(ref, reorder);
        
    }
 
    @Override
    public void replyInsert(BoardDTO dto) {
 
        boardDAO.replyInsert(dto);
        
    }
    
    
    //게시물 삭제
    @Override
    public void boardDelete(int idx) {
        
        
        boardDAO.boardDelete(idx);
    }
 
    @Override
    public void boardUpdate(BoardDTO dto) {
        boardDAO.boardUpdate(dto);
        
    }
 
 
    @Override
    public void deleteFile(String filename) {
        
        try {
            File f=new File("d:\\upload\\"+filename);
            if(f!=null && f.exists()){
                
                f.delete();//파일을 삭제함    
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
        
    }
 
}
 
cs




POM.XML INSERT

1
2
3
4
5
6
7
8
        <!-- json라이브러리 -->
        <!-- https://mvnrepository.com/artifact/com.fasterxml.jackson.core/jackson-databind -->
        <dependency>
            <groupId>com.fasterxml.jackson.core</groupId>
            <artifactId>jackson-databind</artifactId>
            <version>2.5.0</version>
        </dependency>
 
cs




-- det gul  list & comment count query


1
2
3
4
5
6
7
8
9
10
11
12
13
 
 -- det gul  list & comment count query
 
 
 select idx, b.userid,name,subject,hit,post_date,filename,filesize,
    
    (select count(*
     from board_comment
     where board_idx=b.idx) comment_count
 
from board b,member m 
where b.userid=m.userid 
order by idx limit 0,10;





cs


-- detgul pazing



select *

from board_comment b, member m

where b.userid=m.userid

and board_idx = 572

order by comment_idx limit 0,10;


board_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
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
<%@ 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="community"><div>COMMUNITY</div></h1>
          <article>
              <h2>게시판</h2>
              
 
    
    <table border="1" align="center" class="tbl_type" WIDTH=50% table-layout: fixed>
        <tr>
            <th  nowrap WIDTH="40">번호</th>
            <th  nowrap WIDTH="100">이름</th>
            <th  nowrap WIDTH="250">제목</th>
            <th  nowrap WIDTH="100">날짜</th>
            <th  nowrap WIDTH="40">조회</th>
            <th  nowrap WIDTH="70">첨부파일</th>
            <th  nowrap WIDTH="70">다운로드</th>
        </tr>
 
 
        <c:forEach var="row" items="${list}">
            <tr>
                <td>${row.idx }</td>
                <td>${row.username }</td>
                <td>
                
                <!-- 답변 들여쓰기 -->
                <c:forEach begin="1" end="${row.depth }">
                &nbsp;&nbsp;
                </c:forEach>
    
    
 
                <a href="${path}/board/view.do?idx=${row.idx}">
                ${row.subject}</a>
                <c:if test="${row.comment_count >0 }">
            
            <span style="color:red">[${row.comment_count}]</span>
                
                </c:if>
                </td>
    
                <td>${row.post_date}</td>
                <td>${row.hit}</td>
                
                
                <!-- 첨부파일의 사이즈가 보다 크면 파일 다운로드 링크 표시 -->
                
                
                <td align="center">
                <c:if test="${row.filesize > 0 }">
                    <a href="${path}/board/down.do?idx=${row.idx}">
                    <img src="${path}/images/file.gif">
                </a>
                </c:if>
                </td>
 
                <td>${row.down}</td>
            </tr>
        </c:forEach>
 
 
<!-- page navigation -->
<tr align="center">
<td colspan="7">
<!-- 이전 -->
<c:if test="${page.curPage>1 }">
<a href="${path}/board/board_list.do?curPage=1&search_option=${search_option}&search=${search}">[시작] </a>
</c:if>
 
<c:if test="${page.curBlock > 1 }">
<a href="${path}/board/board_list.do?curPage=${page.prevPage}&search_option=${search_option}&search=${search}">[이전] </a>
</c:if>
 
 
 
<c:forEach var="pageNum" begin="${page.blockStart}" end="${page.blockEnd}">
 
<c:choose>
    <c:when test="${pageNum==page.curPage }">
 
    <span style="color:red">[${pageNum}]</span>
    </c:when>
    
    <c:otherwise>
<a href="${path}/board/board_list.do?curPage=${pageNum}&search_option=${search_option}&search=${search}">[${pageNum}] </a>&nbsp;
    </c:otherwise>
</c:choose>
 
</c:forEach>
 
<!-- 다음 -->
 
 
<c:if test="${page.curBlock <= page.totBlock}">
 
<a href="${path}/board/board_list.do?curPage=${page.nextPage}&search_option=${search_option}&search=${search}">[다음] </a>
</c:if>
 
<!-- 마지막 페이지 -->
 
<c:if test="${page.curPage < page.totPage}">
 
<a href="${path}/board/board_list.do?curPage=${page.totPage}&search_option=${search_option}&search=${search}">[끝] </a>
 
</c:if>
</td>
 
</tr>
 
    </table>
 
<br>
<!-- 검색폼 -->
 
    <form method="post" action="${path}/board/board_list.do">
        <div align="center"><select name="search_option">
            <option value="username"
            
            <c:if test= "${search_option =='username'}"> selected </c:if> >
            이름
            </option>
            
            <option value="subject" <c:if test= "${search_option =='subject'}"> selected </c:if> >제목</option>
            <option value="content" <c:if test= "${search_option =='content'}"> selected </c:if> >내용</option>
            <option value="all" <c:if test= "${search_option =='all'}"> selected </c:if> >전체</option>
        </select>
        
        <input type="text" name="search" value="${search}">
        <input type="submit" value="확인">&nbsp;&nbsp;&nbsp;
        <input type="button" id="btnWrite" value="글쓰기"></div>
    </form>    
 
    </article>
          <jsp:include page="boardSidebar.jsp" flush="false"/>
 
          <jsp:include page="boardFooter.jsp" flush="false"/>
 
cs



반응형

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

31.스프링프로젝트 - 조회  (4) 2016.11.21
30.스프링프로젝트 - 답변  (4) 2016.11.21
28.spring - hitup  (4) 2016.11.18
27.springproject - log  (4) 2016.11.18
26.스프링프로젝트 - 페이징 처리  (6) 2016.11.17

댓글