JSP회원가입 및 게시판

<게시판만들기>-게시판 내용보기

byeol2ing 2020. 6. 28. 17:33
반응형

<freeboardList.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

<%@page import="kr.or.ddit.vo.FreeboardVO"%>

<%@page import="java.util.List"%>

<%@page import="kr.or.ddit.freeboard.service.IFreeboardServiceImpl"%>

<%@page import="kr.or.ddit.freeboard.service.IFreeboardService"%>

<%@page import="java.util.HashMap"%>

<%@page import="java.util.Map"%>

<%@ page language="JAVA" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

 

<%

    String search_keyword = request.getParameter("search_keyword");

    String search_keycode = request.getParameter("search_keycode");

    

    Map<StringString> params = new HashMap<StringString>();

    params.put("search_keyword", search_keyword);

    params.put("search_keycode", search_keycode);

    

    IFreeboardService service = IFreeboardServiceImpl.getInstance();

    

    List<FreeboardVO> freeboardList = service.freeboardList(params);

%>

<c:set var="freeboardList" value="<%=freeboardList %>"></c:set>

<c:url var="freeboardFormURI" value="/01/main.jsp">

    <c:param name="contentPage" value="/01/freeboard/freeboardForm.jsp"></c:param>

</c:url>

<c:url var="freeboardViewURI" value="/01/main.jsp">

    <c:param name="contentPage" value="/01/freeboard/freeboardView.jsp"></c:param>

</c:url>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>자유게시글 목록</title>

<script type="text/javascript">

    $(function(){

        $('#freeboardRegistBTN').click(function(){

            if(eval('${!empty sessionScope.LOGIN_MEMBERINFO}')){

                $(location).attr('href''${freeboardFormURI}');

            }else{

                BootstrapDialog.show({

                    title: '알럿창',

                    message: '게시글은 로그인이 완료된 이후 작성할 수 있습니다!'

                });

            }

        });

        

        $('#freeboardTBY tr').click(function(){

            var bo_no = $(this).find('td:eq(0) input').val();

            var rnum = $(this).find('td:eq(0)').text();

            $(location).attr('href','${freeboardViewURI}?bo_no='+bo_no+'&rnum='+rnum);

        });

        

    });

</script>

</head>

<body>

<div id="freeboardList_content">

    <div class="panel panel-blue">

        <div class="panel-heading">게시판 목록</div>

        <table class="table table-bordered table-hover">

            <thead>

                <tr>

                    <th scope="col" width="5%">No</th>

                    <th scope="col" width="65%">제목</th>

                    <th scope="col" width="10%">작성자</th>

                    <th scope="col" width="10%">작성일</th>

                    <th scope="col" width="10%">조회수</th>

                </tr>

            </thead>

            <tbody id="freeboardTBY">

            <c:forEach items="${pageScope.freeboardList }" var="freeboardInfo">

                <tr>

                    <td><input type="hidden" value="${freeboardInfo.bo_no }"/>${freeboardInfo.rnum }</td>

                    <td>${freeboardInfo.bo_title }</td>

                    <td>${freeboardInfo.bo_nickname }</td>

                    <td>${freeboardInfo.bo_reg_date }</td>

                    <td>${freeboardInfo.bo_hit }</td>

                </tr>

            </c:forEach>

            </tbody>

        </table>

    </div>

</div>

<div >

<form action="${pageContext.request.contextPath }/01/main.jsp" method="post" class="form-inline pull-right">

        <input id="search_keyword" name="search_keyword" type="text" placeholder="검색어 입력..." class="form-control" />

        <select class="form-control" name="search_keycode" >

            <option>검색조건</option>

            <option value="TOTAL">전체</option>

            <option value="TITLE">제목</option>

            <option value="CONTENT">내용</option>

            <option value="NICKNAME">작성자</option>

        </select>

        <button type="submit" class="btn btn-primary form-control">검색</button>

        <button type="button" class="btn btn-info form-control" id="freeboardRegistBTN">게시글 등록</button>

</form>

</div>    

</body>

</html>

Colored by Color Scripter

cs



 

<freeboardView.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

<%@page import="kr.or.ddit.vo.FreeboardVO"%>

<%@page import="kr.or.ddit.freeboard.service.IFreeboardServiceImpl"%>

<%@page import="kr.or.ddit.freeboard.service.IFreeboardService"%>

<%@page import="java.util.HashMap"%>

<%@page import="java.util.Map"%>

<%@ page language="JAVA" contentType="text/html; charset=UTF-8"

    pageEncoding="UTF-8"%>

<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>

<%

    String bo_no = request.getParameter("bo_no");

    Map<StringString> params = new HashMap<StringString>();

    params.put("bo_no", bo_no);

    

    IFreeboardService service = IFreeboardServiceImpl.getInstance();

    FreeboardVO freeboardInfo = service.freeboardInfo(params);

%>

 

<c:set var="freeboardInfo" value="<%=freeboardInfo %>"></c:set>

<!DOCTYPE html>

<html>

<head>

<meta charset="UTF-8">

<title>자유게시글 정보</title>

<!-- 이미지 슬라이드 사이즈 조정 -->

<style type="text/css">

.carousel{

    width:200px;

    height:150px;

    margin-left: 200px;

}

.carousel-inner > .item > img{

    width:200px;

    height:150px;

}       

</style>

<script>

$(function(){

    // 섬머노트를 div를 활용한 textarea에 추가.

    // http://summernote.org 활용

    $('#bo_content').summernote({

            height: 150,

            codemirror: {

            theme: 'monokai'

        }

    });

    

 // 도큐먼트 초기값 설정

    $('#bo_title').val('${freeboardInfo.bo_title}');

    $('#bo_nickname').val('${freeboardInfo.bo_nickname}');

    $('#bo_pwd').val('${freeboardInfo.bo_pwd}');

    $('#bo_mail').val('${freeboardInfo.bo_mail}');

    $('#bo_content').summernote('code''${freeboardInfo.bo_content}');

    

    

    

});

</script>

</head>

<body>

<form class="form-horizontal" role="form" action="" method="post">

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_title">제목:</label>

        <div class="col-sm-10">

            <input type="text" class="form-control" id="bo_title" name="bo_title" >

        </div>

    </div>

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_nickname">작성자 대화명:</label>

        <div class="col-sm-10"> 

            <input type="text" class="form-control" id="bo_nickname" name="bo_nickname" >

        </div>

    </div>

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_pwd">패스워드:</label>

        <div class="col-sm-10"> 

            <input type="password" class="form-control" id="bo_pwd" name="bo_pwd" >

        </div>

    </div>

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_mail">메일:</label>

        <div class="col-sm-10"> 

            <input type="text" class="form-control" id="bo_mail" name="bo_mail" >

        </div>

    </div>

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_content">내용:</label>

        <div class="col-sm-10"> 

            <div id="bo_content"><p></p></div>

        </div>

    </div>

    <div class="form-group">

        <label class="control-label col-sm-2" for="bo_content">첨부파일:</label>

        <div id="myCarousel" class="carousel slide" data-ride="carousel">

            <!-- Indicators -->

            <ol class="carousel-indicators">

                <li data-target="#myCarousel" data-slide-to="0" class="active"></li>

                <li data-target="#myCarousel" data-slide-to="1"></li>

                <li data-target="#myCarousel" data-slide-to="2"></li>

                <li data-target="#myCarousel" data-slide-to="3"></li>

            </ol>

    

            <!-- Wrapper for slides -->

            <div class="carousel-inner" role="listbox" style="height: 200px;">

                <div class="item active">

                    <img src="./images/thumbs/arch-1.jpg" alt="pic1">

                </div>

        

                <div class="item">

                    <img src="./images/thumbs/arch-2.jpg" alt="pic2">

                </div>

        

                <div class="item">

                    <img src="./images/thumbs/autumn-1.jpg" alt="pic3">

                </div>

        

                <div class="item">

                    <img src="./images/thumbs/boats-1.jpg" alt="pic4">

                </div>

            </div>

            <!-- Left and right controls -->

            <a class="carousel-control left" href="#myCarousel" data-slide="prev">&lsaquo;</a>

            <a class="carousel-control right" href="#myCarousel" data-slide="next">&rsaquo;</a>

        </div>

    </div>

    <div class="form-group"> 

        <div class="col-sm-offset-2 col-sm-10">

            <button type="button" class="btn btn-success">글쓰기</button>

            <button type="button" class="btn btn-danger">삭제</button>

            <button type="button" class="btn btn-primary">답글</button>

            <button type="button" class="btn btn-info">목록</button>

            <button type="submit" class="btn btn-default" style="float: right">수정</button>

        </div>

    </div>

</form>

</body>

</html>

Colored by Color Scripter

cs

<freeboard.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

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

<?xml version="1.0" encoding="UTF-8" ?>

<!DOCTYPE sqlMap   

    PUBLIC "-//ibatis.apache.org//DTD SQL Map 2.0//EN"      

    "http://ibatis.apache.org/dtd/sql-map-2.dtd">

 

<sqlMap namespace="freeboard">

<typeAlias alias="freeboardVO" type="kr.or.ddit.vo.FreeboardVO"/>

 

    <sql id="selectAll">

        SELECT *

         FROM FREEBOARD

        WHERE BO_STATUS = 'n'

    </sql>

    

    <sql id="searchCondition">

        <dynamic prepend="AND">

            <isNotEmpty property="search_keyword" open="(" close=")">

                <isEqual property="search_keycode" compareValue="TOTAL">

                    BO_TITLE LIKE '%' || #search_keyword# || '%'

                    OR BO_CONTENT LIKE '%' || #search_keyword# || '%'

                    OR BO_NICKNAME LIKE '%' || #search_keyword# || '%'

                </isEqual>

                <isEqual property="search_keycode" compareValue="TITLE">

                    BO_TITLE LIKE '%' || #search_keyword# || '%'

                </isEqual>

                <isEqual property="search_keycode" compareValue="CONTENT">

                    BO_CONTENT LIKE '%' || #search_keyword# || '%'

                </isEqual>

                <isEqual property="search_keycode" compareValue="NICKNAME">

                    BO_NICKNAME LIKE '%' || #search_keyword# || '%'

                </isEqual>

            </isNotEmpty>

        </dynamic>

    </sql>

 

    <select id ="freeboardList" parameterClass="map" resultClass="freeboardVO">

        

        <include refid="selectAll"/>

        <include refid="searchCondition"/>

         

    </select>

    

    <insert id="insertFreeboard" parameterClass="freeboardVO" >

        <selectKey keyProperty="bo_no" resultClass="String">

            SELECT FREEBOARD_SEQ.NEXTVAL FROM DUAL

        </selectKey>

        INSERT INTO

            FREEBOARD(

                 BO_NO       

                ,BO_TITLE    

                ,BO_WRITER   

                ,BO_NICKNAME 

                ,BO_PWD      

                ,BO_MAIL     

                ,BO_IP       

                ,BO_CONTENT  

                ,BO_GROUP    

            )

            VALUES(

                 #bo_no#

                ,#bo_title#

                ,#bo_writer#

                ,#bo_nickname#

                ,#bo_pwd#

                ,#bo_mail#

                ,#bo_ip#

                ,#bo_content#

                ,#bo_no#

                )

    </insert>

    

    <select id="freeboardInfo" parameterClass="map" resultClass="freeboardVO">

        <include refid="selectAll"/>

        AND bo_no = #bo_no#

    </select>    

    

</sqlMap>

 

 

 

 

 

 

Colored by Color Scripter

cs
반응형