<freeboadList.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 |
<%@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<String, String> params = new HashMap<String, String>(); 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> <!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: '게시글은 로그인이 완료된 이후 작성할 수 있습니다!' }); } }); }); </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> <c:forEach items="${pageScope.freeboardList }" var="freeboardInfo"> <tr> <td>${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> |
cs |
validation.js
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 |
/** * */
String.prototype.validationID = function(){ return /^[a-z][0-9]{3}$/.test(this); }; String.prototype.validationPWD = function(){ return /^[a-z0-9]{4,15}$/.test(this); };
String.prototype.validationTITLE = function(){ return /^[가-힣a-zA-Z ]{1,30}$/.test(this); }; String.prototype.validationNICKNAME = function(){ return /^[가-힣]{2,5}$/.test(this); }; String.prototype.validationMAIL = function(){ //test@test.com or test@test.co.kr return /^[a-z0-9]+@[a-z]+(\.[a-z]+){1,2}$/.test(this); };
|
cs
|
<freeboardForm.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 |
<%@ page language="JAVA" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <c:url var="insertFreeboardURI" value="/01/freeboard/insertFreeboardInfo.jsp"></c:url> <!DOCTYPE html> <html> <head> <meta charset="UTF-8"> <title>자유게시글 등록</title> <script type="text/javascript"> $(function(){ // 섬머노트를 div를 활용한 textarea에 추가. // http://summernote.org 활용 $('#bo_content').summernote({ lang: 'ko-KR', height: 150, codemirror: { theme: 'monokai' } });
$('form[name=freeboardForm]').submit(function(){ if(!$('#bo_title').val().validationTITLE()){ return alertPrint("제목을 바르게 입력해주세요"); } if(!$('#bo_nickname').val().validationNICKNAME()){ return alertPrint("대화명을 바르게 입력해주세요."); } if(!$('#bo_mail').val().validationMAIL()){ return alertPrint("메일을 바르게 입력해주세요"); }
var bo_content = $('#bo_content').summernote('code');
$(this).append('<input type="hidden" name="bo_content" value="'+bo_content+'"/>');
$(this).append('<input type="hidden" name="bo_writer" value="${LOGIN_MEMBERINFO.mem_id}"/>'); $(this).append('<input type="hidden" name="bo_ip" value="${pageContext.request.remoteAddr}"/>'); $(this).attr('action','${insertFreeboardURI}');
return true; }); // 포커스 처리 // $('#bo_content').summernote( {focus: true} ); // 값 취득 // $('#bo_content').summernote('code'); // 값 추가 // $('#bo_content').summernote('code', '<font color="red">추가글</font>'); // 에디터 제거 // $('#bo_content').summernote('destroy');
/* BootstrapDialog.show({ title: '알럿창', message: '알럿창으로 활용하세요!' });
BootstrapDialog.show({ message: '컨펌 다이얼로그로 활용하세요!', buttons: [{ label: 'Button 1' }, { label: 'Button 2', cssClass: 'btn-primary', action: function(){ alert('Hi Orange!'); } }, { icon: 'glyphicon glyphicon-ban-circle', label: 'Button 3', cssClass: 'btn-warning' }, { label: 'Close', action: function(dialogItself){ dialogItself.close(); } }] }); */
});
function alertPrint(msg){ BootstrapDialog.show({ title: '알림', message: msg }); return false; }
</script> </head> <body> <form name="freeboardForm" 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" placeholder="제목 입력..."> </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" placeholder="대화명 입력..."> </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" placeholder="패스워드 입력..."> </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" placeholder="메일주소 입력..."> </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="file01">첨부파일1:</label> <div class="col-sm-10"> <input type="file" class="filestyle" id="file01" name="file01" data-buttonName="btn-primary"> </div> </div> <div class="form-group"> <label class="control-label col-sm-2" for="file02">첨부파일2:</label> <div class="col-sm-10"> <input type="file" class="filestyle" id="file02" name="file02" data-buttonName="btn-primary"> </div> </div> <div class="form-group"> <div class="col-sm-offset-2 col-sm-10"> <button type="submit" class="btn btn-info" style="float: right">등록</button> <button type="button" class="btn btn-danger" style="float: right">취소</button> <button type="button" class="btn btn-primary" style="float: right">목록</button> </div> </div> </form> </body> </html> |
cs
|
<insertFreeboardInfo.jsp>
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
<%@page import="kr.or.ddit.freeboard.service.IFreeboardServiceImpl"%> <%@page import="kr.or.ddit.freeboard.service.IFreeboardService"%> <%@page import="org.apache.commons.beanutils.BeanUtils"%> <%@page import="kr.or.ddit.vo.FreeboardVO"%> <%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <% request.setCharacterEncoding("UTF-8"); FreeboardVO freeboardInfo = new FreeboardVO(); BeanUtils.populate(freeboardInfo, request.getParameterMap()); IFreeboardService service = IFreeboardServiceImpl.getInstance(); service.insertFreeboard(freeboardInfo); response.sendRedirect(request.getContextPath() + "/01/main.jsp"); %> |
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 |
<?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> </sqlMap>
|
cs |
'JSP회원가입 및 게시판' 카테고리의 다른 글
<게시판만들기>-게시판 내용보기 (0) | 2020.06.28 |
---|---|
<게시판만들기>-게시판 출력하기 (0) | 2020.06.28 |
<게시판만들기>-RSA 암호화를 이용하여 로그인하기 (2) | 2020.06.28 |
<게시판만들기>-main.jsp(JSTL) (0) | 2020.06.25 |
main.jsp (0) | 2020.06.21 |