Coding/전자정부프레임

게시판 : 페이징 루트

찡콩찡 2022. 5. 25. 16:12

페이징 루트 잊어버리지 말자! 

페이징

아래와 같이 페이징라벨스를 수정해준다.

public void initVariables(){
		firstPageLabel    = "<a href=\"{0}&amp;pageIndex= {1}\" class=\"first\" title=\"처음페이지로이동\"><span>처음</span></a>";
	    previousPageLabel = "<a href=\"{0}$amp;pageIndex= {1}\" class=\"prev\" title=\"이전페이지로 이동\"><span>이전</span></a>";
        currentPageLabel  = "<strong class=\"current\">{0}</strong>";
        otherPageLabel    = "<a href=\"{0}&amp;pageIndex= {1}\" class=\"page\" title=\"{2}페이지로 이동\">{2}</a>";
        nextPageLabel     = "<a href=\"{0}&amp;pageIndex= {1}\" class\"next\" title=\"다음페이지로 이동\"><span>다음</span></a>";
        lastPageLabel     = "<a href=\"{0}&amp;pageIndex= {1}\" class\"last\" title=\"마지막페이지로 이동 \"><span>마지막</span></a>";
	}

insert 작성하기
<<< Regist 등록하는 페이지 >>>>

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>    
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-sacle=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>수업용 게시판</title>
<!-- BBS Style -->
<link href="/asset/BBSTMP_0000000000001/style.css" rel="stylesheet"/>
<!-- 공통 style -->
<link href="/asset/LYTTMP_0000000000000/style.css" rel="stylesheet"/>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<c:choose>
	<c:when test="${not empty searchVO.boardId}">
		<c:set var="actionUrl" value="/board/update.do"/>
	</c:when>
	<c:otherwise>
		<c:set var="actionUrl" value="/board/insert.do"/>
	</c:otherwise>
</c:choose>
<========================================================================================>
onsubmit:유효성 검사를 할때 사용 

<div class="container"> 
<div id="contents">
	<form action="${actionUrl}" method="post" id="frm" name="frm" onsubmit="return regist()">
		<input type="hidden" name="boardId" value="${reseult.boardId}"/>
		
	<table class="chart2">
		<caption>게시글 작성</caption>   //caption:테이블안에 있는 제목을 의미 꼭 무조건 들어가야함
		<colgroup>                      //colgroup:열 너비 조정
			<col style="width:120px"/>
			<col /> 					//나머지 값을 가져간다.디바이스 크기에 따라 그래서 두번째 col은 값이 없음 
		</colgroup>
		<tbody>  						//왜 thead가 없고 바로 tbody로 시작할까? thead가 세로로 작성되어 있어서
			<tr>
				<th scope="row">제목</th>  //scope row: 세로로 설명이 되어있다 col:가로로 설명되어있다. 라는 의미 
				<td>
					<input type="text" id="boardSj" name="boardSj" title="제목입력" class="q3" value="<c:out value=${result.boardSj}"/>"/>
				</td>
			</tr>
				<tr>
					<th scope="row">공지여부</th>
					<td>
						<label for="noticeAty">예 :</label>
						<input type="radio" id="noticeAtY(공지여부)" value="Y" name="noticeAt" <c:if test="${result.noticeAt eq 'Y'}">checked="checked"</c:if>/>/&nbsp;&nbsp;&nbsp;
					    <label for="noticeAty">아니오 :</label>
						<input type="radio" id="noticeAtN" value="N" name="noticeAt" <c:if test="${result.noticeAt ne 'Y'(아니오가 default 값 처음이 null값일 수 있어서)}">checked="checked"</c:if>/>
					</td>
				</tr>
				<tr>
					<th scope="row">비공개여부</th>
					<td>
						<label for="noticeAtY">예:  </label>
						<input type="radio" id="othbAtY" value="Y" name="othbcAt" <c:if test="${result.othbcAt eq 'Y'}">checked="cheked"</c:if>/>&nbsp;&nbsp;&nbsp;
                        //checked 사용 시 자동으로 check가 될 수 있게 해줌 radio(하나만 택)와 check(여러개 체크 가능)의 차이점
                        
						<label for="noticeAtN">아니오:</label>  //아니오가 디폴트 값
						<input type="radio" id="othbAtN" value="N" name="othbcAt" <c:if test="${result.othbcAt ne 'Y'}">checked="cheked"</c:if>/>
					</td>
				<tr>
					<th scope="row">작성자ID<th>
					<td>
						<c:out value="${USER_INFO.id}"/> 
					</td>
				</tr>
				<tr>
					<th scope="row">내용</th>
					<td>
						<textarea id="boardCn" name="boardCn" rows="15" title="내용입력"><c:out value="${result.boardCn}"/></textarea> //textarea는 한줄에 쓰는게 맞음(무조건 붙여서 쓰자) 데이터의 정확성 때문에
					<td>
				</tr>		
		</tbody>	
	</table>
	<div class="btn-cont ar">
		<c:choose>
			<c:when test="${not empty searchVO.boardId}">
				<c:url var="uptUrl" value="/board/update.do">
					<c:param name="boardId" value="${result.boardId}"/>
				</c:url> 
                
                //수정과 삭제는 작성자와 관리자만 가능해야하는데 그 소스가 여기에는 없다. 
                //왜? 컨트롤러에서 이미 수정과 삭제 처리를 완료함 그래서 jsp에서 따로 표현하지 않음 controller에서 '//게시물 등록&수정' 코드 확인하기
				
                <a href="${uptUrl}" id="btn-reg" calss="btn">수정</a>
				<c:url var="delUrl" value="/board/delete.do">
					<c:param name="boardId" value="${result.boardId}"/>
				</c:url>
				<a href="${delUrl}" id="btn-del" class="btn"> <i class="ico-del"></i> 삭제</a>
			<c:when>
			<c:otherwise>
				<a href="#none" id="btn-reg" class="btn spot">등록</a>
			</c:otherwise>
			<c:url var="listUrl" value="/board/selectList.do"/>
			<a href="${listUrl}" class="btn">취소</a>
         </div>
      </form>
   </div>
</div>
<script>
$(document).ready(function() { //소스 전체가 랜더링 후에 document를 실행하라
	//게시글 등록   
	$("#btn-reg").click(function(){  //클릭하면 이 function이 실행
		$("#frm").submit();
		return false; //이벤티가 여러번 발생하면 안되니까 false로 처리
	});
    
	//게시 글 삭제
	$("#btn-del").click(function(){
		if(!confirm("삭제하시겠습니까?")){
			return false; // return false라는 의미 : 클릭 이벤트를 가진 태그의 기능을 비활성화 시키는 것 / 레이어사용시 많이 씀
		}
	});
});

function regist(){
	if(!$("boardSj").val()) { //!는 아니면 이라는 의미 var가 value값을 받아오는것 val가 없으면 그냥 제목을 입력해주세요 라는 경고문이 나옴
		alert("제목을 입력해주세요");
		return false;  // 바로 종료시키는 것
	}
}
</script>
</body>
</html>

 

 

 

selectList 파일 복사해서 regist 파일에 넣는다.

아래와 같이 수정한다. 

**controller**

package egovframework.let.board.web;
import java.util.List;

import egovframework.com.cmm.LoginVO;
import egovframework.com.cmm.util.EgovUserDetailsHelper;
import egovframework.let.board.service.BoardService;
import egovframework.let.board.service.BoardVO;
import egovframework.let.utl.fcc.service.EgovStringUtil;


import egovframework.rte.psl.dataaccess.util.EgovMap;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;



@Controller
public class BoardController {

	@Resource(name = "boardService")
	private BoardService boardService;
		
	
	//게시목록 가져오기
	@RequestMapping(value = "/board/selectList.do")
	public String selectList(@ModelAttribute("searchVO") BoardVO searchVO, HttpServletRequest request, ModelMap model) 
	throws Exception { 
	
	//공지 게시글
    searchVO.setNoticeAt("Y");
    List<EgovMap> noticeResultList = boardService.selectBoardList(searchVO);
    model.addAttribute("noticeResultList", noticeResultList);

	PaginationInfo paginationInfo = new PaginationInfo();	
	paginationInfo.setCurrentPageNo(searchVO.getPageIndex() );
	paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
	paginationInfo.setPageSize(searchVO.getPageSize() );	
	searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex() );
	searchVO.setLastIndex(paginationInfo.getLastRecordIndex() );
	searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage() );
	
	searchVO.setNoticeAt("N");
	List<EgovMap> resultList = boardService.selectBoardList(searchVO);
	model.addAttribute("resultList", resultList);
	
	int totCnt = boardService.selectBoardListCnt(searchVO);
	
	paginationInfo.setTotalRecordCount(totCnt);
	model.addAttribute("paginationInfo" , paginationInfo);
	
	//새롭게 추가
	LoginVO user =(LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
	model.addAttribute("USER_INFO",user);
	
	return "board/BoardSelectList";
	
	}
	//게시물 등록 & 수정 :세션에 저장된 로그인 정보를 가져오는구나! 라고 생각해보자
	@RequestMapping(value = "board/boardRegist.do")
	public String boardRegist(@ModelAttribute("searchVO") BoardVO boardVO,HttpServletRequest request, ModelMap model) throws Exception{
		LoginVO user = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
		if(user == null  || user.getId() == null) { //로그인을 해야하만 사용가능하도록 로직을 씀
			model.addAttribute("message", "로그인 후 사용 가능합니다.");
			return "forward:/board/selectList.do";
		}
		else {  //로그인 해당 정보가 있다면 else 문을 실행
			model.addAttribute("USER_INFO", user);
		}
		
		BoardVO result = new BoardVO(); //수정페이지와 등록 페이지가 동일하게 사용함
		if(!EgovStringUtil.isEmpty(boardVO.getBoardId())) {
			
			result = boardService.selectBoard(BoardVO); 
			//본인 관리자만 허용 , 비밀글 사용시 쓰는 로직, 관리자만 수정할 수 있는 페이지
			if(!user.getId().equals(result.getFrstRegisterId()) && ! "admin".equals(user.getId())) {
				model.addAttribute("message", "작성자 본인만 확인 가능합니다.");
				return "forward:/board/selectList.do";	
			}
		
		}
		model.addAttribute("result", result);
		request.getSession().removeAttribute("sessionBoard");
		
		return "board/BoardRegist";
	}
}

 

 

컨트롤러
package egovframework.let.board.web;
import java.util.List;

import egovframework.com.cmm.LoginVO;
import egovframework.com.cmm.util.EgovUserDetailsHelper;
import egovframework.let.board.service.BoardService;
import egovframework.let.board.service.BoardVO;
import egovframework.let.utl.fcc.service.EgovStringUtil;


import egovframework.rte.psl.dataaccess.util.EgovMap;
import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;


import org.springframework.stereotype.Controller;
import org.springframework.ui.ModelMap;

import org.springframework.web.bind.annotation.ModelAttribute;
import org.springframework.web.bind.annotation.RequestMapping;



@Controller
public class BoardController {

	@Resource(name = "boardService")
	private BoardService boardService;
		
	
	//게시목록 가져오기
	@RequestMapping(value = "/board/selectList.do")
	public String selectList(@ModelAttribute("searchVO") BoardVO searchVO, HttpServletRequest request, ModelMap model) 
	throws Exception { 
	
	//공지 게시글
    searchVO.setNoticeAt("Y");
    List<EgovMap> noticeResultList = boardService.selectBoardList(searchVO);
    model.addAttribute("noticeResultList", noticeResultList);

	PaginationInfo paginationInfo = new PaginationInfo();	
	paginationInfo.setCurrentPageNo(searchVO.getPageIndex() );
	paginationInfo.setRecordCountPerPage(searchVO.getPageUnit());
	paginationInfo.setPageSize(searchVO.getPageSize() );	
	searchVO.setFirstIndex(paginationInfo.getFirstRecordIndex() );
	searchVO.setLastIndex(paginationInfo.getLastRecordIndex() );
	searchVO.setRecordCountPerPage(paginationInfo.getRecordCountPerPage() );
	
	searchVO.setNoticeAt("N");
	List<EgovMap> resultList = boardService.selectBoardList(searchVO);
	model.addAttribute("resultList", resultList);
	
	int totCnt = boardService.selectBoardListCnt(searchVO);
	
	paginationInfo.setTotalRecordCount(totCnt);
	model.addAttribute("paginationInfo" , paginationInfo);
	
	//새롭게 추가
	LoginVO user =(LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
	model.addAttribute("USER_INFO",user);
	
	return "board/BoardSelectList";
	
	}
	//게시물 등록 & 수정
	@RequestMapping(value = "board/boardRegist.do")
	public String boardRegist(@ModelAttribute("searchVO") BoardVO boardVO,HttpServletRequest request, ModelMap model) throws Exception{
		LoginVO user = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
		if(user == null  || user.getId() == null) {
			model.addAttribute("message", "로그인 후 사용 가능합니다.");
			return "forward:/board/selectList.do";
		}
		else {
			model.addAttribute("USER_INFO", user);
		}
		
		BoardVO result = new BoardVO();
		if(!EgovStringUtil.isEmpty(boardVO.getBoardId())) {
			/*
			result = boardService.selectBoard(BoardVO);
			//본인 관리자만 허용
			if(!user.getId().equals(result.getFrstRegisterId()) && ! "admin".equals(user.getId())) {
				model.addAttribute("message", "작성자 본인만 확인 가능합니다.");
				return "forward:/board/selectList.do";	
			}
			*/
		}
		model.addAttribute("result", result);
		request.getSession().removeAttribute("sessionBoard");
		
		return "board/BoardRegist";
	}
	
	
	//등록 페이지		
  @RequestMapping(value = "/board/insert.do")
  public String insert(@ModelAttribute("searchVO") BoardVO searchVO,
		HttpServletRequest request, ModelMap model) throws Exception{
	
	//이중 서브밋 방지 체크
	if(request.getSession().getAttribute("sessionBoard") != null) {
		return "forward:/board/selectList.do";
	}
	LoginVO user = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
	if(user == null || user.getId() == null) {
		model.addAttribute("message", "로그인 후 사용가능합니다");
		return "forward:/board/selectList.do";
		}
		searchVO.setCreatIp(request.getRemoteAddr());
		searchVO.setUserId(user.getId());
		
		boardService.insertBoard(searchVO);
		
		//이중 서브밋 방지
		request.getSession().setAttribute("sessionBoard", searchVO);
		return "forward:/board/selectList.do";
	}
	
}

 

 

서비스

package egovframework.let.board.service;

import java.util.List;

import egovframework.rte.psl.dataaccess.util.EgovMap;


public interface BoardService {
	
	//게시물 목록 가져오기
	public List<EgovMap> selectBoardList(BoardVO vo) throws Exception;
		
	//게시물 목록 수
	public int selectBoardListCnt(BoardVO vo) throws Exception;
	
	//게시물 등록하기
	public String insertBoard(BoardVO vo) throws Exception;
}

service impl

//게시물 등록
	@Override
	public String insertBoard(BoardVO vo) throws Exception { 
		String id = idgenService.getNextStringId();
		vo.setBoardId(id);
		boardMapper.insertBoard(vo);
		
		return id;
   }

mapper

//게시물 등록 수 
		void insertBoard(BoardVO vo) throws Exception;

sql </sql>끝난 시점과 mapper안에 작성

<insert id="insertBoard" parameterType="egovframework.let.board.service.BoardVO">
 		INSERT INTO BOARD (
 		BOARD_ID
 		, BOARD_SJ
 		, BOARD_CN
 		, INQIRE_CO  <!-- 조회수를 의미 -->
 		, CREAT_IP  
 		, NOTICE_AT
 		, OTHBC_AT
 		, USE_AT
 		, ATCH_FILE_ID
 		, FRST_REGIST_PNTTM
 		, FRST_REGISTER_ID
 		, LAST_UPDT_PNTTM
 		, LAST_UPDUSR_ID
 		) VALUES (
 		  #{boardId}
 		 , #{boardSj}
 		 , #{boardCn}
 		 , 0
 		 , #{creatIp}
 		 , #{noticeAt}
 		 , #{othbcAt}
 		 , #'Y'
 		 , #{atchFileId}
 		 , NOW()
 		 , #{userId}
 		 , NOW()
 		 , #{userId}
 		
 		)
        
 	</insert>

controller 설명

	//등록 페이지		
  @RequestMapping(value = "/board/insert.do")
  public String insert(@ModelAttribute("searchVO") BoardVO searchVO,
		HttpServletRequest request, ModelMap model) throws Exception{
	
	//이중 서브밋 방지 체크
	if(request.getSession().getAttribute("sessionBoard") != null) { 
    //널일 수가 없음 밑에 작성해놨기 때문에 리스트 페이지로 이동 인서트 후에 f5를 눌러도 인서트 페이지가는 코드 
		return "forward:/board/selectList.do";
	}
	LoginVO user = (LoginVO)EgovUserDetailsHelper.getAuthenticatedUser();
	if(user == null || user.getId() == null) {
		model.addAttribute("message", "로그인 후 사용가능합니다");
		return "forward:/board/selectList.do";  //로그인한 페이지
		}
		searchVO.setCreatIp(request.getRemoteAddr()); //공인ip가 저장됨,현재 작성자 기준 ip
		searchVO.setUserId(user.getId());  //user에 대한 아이디를 만들어서 받는것
		
		boardService.insertBoard(searchVO);


//이중 서브밋 방지
		request.getSession().setAttribute("sessionBoard", searchVO); 
        //세션에 저장해서  세선보드라는 것을 서치브이오에 담겨있음  다 생성을 하고 방지를 써준다.
 		f5를 누르면 
		return "forward:/board/selectList.do";

 

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>    
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    

<%--기본url --%>
<c:url var="_BASE_PARAM" value="">	
	<c:param name="menuNo" value="50"/>
	<c:if test="${not empty searchVO.searchCondition}">
		<c:param name="searchCondition" value="${searchVO.searchCondition}"/>
	</c:if>
	<c:if test="${not empty searchVO.searchKeyword}">
		<c:param name="searchKeyword" value="${searchVO.searchKeyword}"/>
	</c:if>
</c:url>
	
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-sacle=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>수업용 게시판</title>
<!-- BBS Style -->
<link href="/asset/BBSTMP_0000000000001/style.css" rel="stylesheet"/>
<!-- 공통 style -->
<link href="/asset/LYTTMP_0000000000000/style.css" rel="stylesheet"/>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<div class="container">
	<div id="contents">
		<%-- 검색영역 --%>
		<div id= "bbs_search">
			<form name="frm" method="post" action="/board/selectList.do">
			<fieldset>
				<legend>검색조건입력폼</legend>
				<label for="ftext" class="hdn">검색분류선택</label>
				<select name="searchCondition" id="ftext">
					<option value="0" <c:if test="${searchVO.searchCondition eq '0'}"> selected="selected"</c:if>>제목</option>
					<option value="1" <c:if test="${searchVO.searchCondition eq '1'}"> selected="selected"</c:if>>내용</option>
					<option value="2" <c:if test="${searchVO.searchCondition eq '2'}"> selected="selected"</c:if>>작성자</option>
				</select>
				
				<label for="inp_text" clasee="hdn">검색어 입력</label>
				<input name="searchKeyword" value="<c:out value="${searchVO.searchKeyword}"/>" type="text" class="inp_s" id="inp_text"/>
				<span class="bbtn_s">
					<input type="submit" value="검색" title="검색(수업용 게시판 게시물 내)"/>
				</span>
			</fieldset>			
			</form>
		</div>
		
		<%-- 목록영역 --%>
		<div id="bbs_wrap">
			<div class="total">
			  총게시물
			  <strong><c:out value="${paginationInfo.totalRecordCount}"/></strong>건 | 현재페이지 <strong><c:out value="${paginationInfo.currentPageNo}"/></strong>/<c:out value="${paginationInfo.totalPageCount}"/>
			</div>
			<div class="bss_list">
				<table class="list_table">
					<thead>
						<tr>
							<th class="num" scope="col">번호</th>
							<th class="tit" scope="col">제목</th>
							<th class="writer" scope="col">작성자</th>
							<th class="date" scope="col">작성일</th>
							<th class="hits" scope="col">조회수</th>
						</tr>
					</thead>
				    <tbody>
				    
	    <%--공지글 --%>
	    <c:forEach var="result" items="${noticeResultList}" varStatus="status">
	    	<tr calss="notice">
	    		<td class="num"><span class="label-bbs spot">공지</span></td>
	    		<td class"tit">
	    			<c:url var="veiwUrl" value="/board/select.do${_BASE_PARAM}">
	    				<c:param name="boardId" value="${result.boardId}"/>
	    				<c:param name="pageIndex" value="${searchVO.pageIndex}"/>
	    			</c:url>
	    			<a href="${viewUrl}"><c:out value="${result.boardSj}"/></a>
	    		</td>
	    		<td class="writer" data-cell-header="작성자:  ">
	    			<c:out value="${result.frstRegisterId}"/>
	    		</td>
	    		<td class="date" data-cell-header="작성일:  ">
	    			<fmt:formatDate value="${result.frstRegisterId}" pattern="yyy-MM-dd"/>
	    		</td>
	    		<td class="hits" data-cell-header="조회수:  ">
	    			<c:out value="${result.inqireCo}"/>
	    		</td>
	    	</tr>
	    	</c:forEach>
	
	   <%--일반글--%>
	   <c:forEach var="result" items="${resultList}" varStatus="status">
	   	<tr>
	   		<td class="num">
				<c:out value="${paginationInfo.totalRecordCount - ((searchVO.pageIndex-1) * searchVO.pageUnit) - (status.count -1)}"/>	
			</td>
			<td class="tit">
				<c:url var="veiwUrl" value="/board/select.do${_BASE_PARAM}">
					<c:param name="boardId" value="${result.boardId}"/>
					<c:param name="pageIndex" value="${searchVO.pageIndex}"/>
				</c:url>
				<a href="${viewUrl}">
				<c:if test="${result.othbcAt eq 'Y'}">
				<img src="/asset/BBSTMP_0000000000001/images/ico_board_lock.gif" alt="비밀 글 아이콘"/>
				</c:if>
				<c:out value="${result.boardSj}"/>
			</a>
			</td>
			
			<td class="writer" date-cell-header="작성자 :  ">
				<c:out value="${result.frstRegisterId}"/>
			</td>
			<td class="date" date-cell-header="작성일 :  ">
				<fmt:formatDate value="${result.frstRegistPnttm}" pattern="yyyy-MM-dd"/>
			</td>
			<td class="hits" date-cell-header="조회수 :  "><c:out value="${result.inqireCo}"/></td>
			</tr>
			</c:forEach>
			
		<%-- 게시글이 없는 경우--%>
		<c:if test="${fn:length(resultList) == 0}">
			<tr class="empty"><td colspan="5">검색데이터가 없습니다.</td></tr> 
		</c:if>
	</tbody>
</table>
</div>
<div id="paging">
	<c:url var="pageUrl" value="/board/selectList.do${_BASE_PARAM}"/>
	<c:set var="pagingParam"><c:out value="${pageUrl}"/></c:set>
	<ui:pagination paginationInfo="${paginationInfo}" type="image" jsFunction="${paginParam}"/>
  </div>
 </div>
 <div class="btn-cont ar">
 	<a href="/board/boardRegist.do" class="btn spot"><i class="ico-check-spot"></i> 글쓰기</a>
     </div>
   </div>
</div>

<script>
<c:if test="${not empty message}">
	alert("${message}");
</c:if>
</script>		
</body>
</html>
BoardRegist

<%@ page language="java" contentType="text/html; charset=UTF-8"
    pageEncoding="UTF-8"%>
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> 
<%@ taglib prefix="ui" uri="http://egovframework.gov/ctl/ui" %>    
<%@ taglib uri="http://java.sun.com/jsp/jstl/functions" prefix="fn" %>  
<%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %>    


<!DOCTYPE html>
<html>
<head>
<meta http-equiv="Content-Language" content="ko">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width,initial-scale=1.0,minimum-sacle=1.0,maximum-scale=1.0,user-scalable=no"/>
<title>수업용 게시판</title>
<!-- BBS Style -->
<link href="/asset/BBSTMP_0000000000001/style.css" rel="stylesheet"/>
<!-- 공통 style -->
<link href="/asset/LYTTMP_0000000000000/style.css" rel="stylesheet"/>
<script src="http://code.jquery.com/jquery-latest.min.js"></script>
</head>
<body>

<c:choose>
	<c:when test="${not empty searchVO.boardId}">
		<c:set var="actionUrl" value="/board/update.do"/>
	</c:when>
	<c:otherwise>
		<c:set var="actionUrl" value="/board/insert.do"/>
	</c:otherwise>
</c:choose>

<div class="container">
<div id="contents">
	<form action="${actionUrl}" method="post" id="frm" name="frm" onsubmit="return regist()">
		<input type="hidden" name="boardId" value="${reseult.boardId}"/>
		
	<table class="chart2">
		<caption>게시글 작성</caption>
		<colgroup>
			<col style="width:120px"/>
			<col />
		</colgroup>
		<tbody>
			<tr>
				<th scope="row">제목</th>
				<td>
					<input type="text" id="boardSj" name="boardSj" title="제목입력" class="q3" value="<c:out value="${result.boardSj}"/>"/>
				</td>
			</tr>
				<tr>
					<th scope="row">공지여부</th>
					<td>
						<label for="noticeAtY">예 : </label>
						<input type="radio" id="noticeAtY" value="Y" name="noticeAt" <c:if test="${result.noticeAt eq 'Y'}">checked="checked"</c:if>/>&nbsp;&nbsp;&nbsp;
					    <label for="noticeAtN">아니오 :</label>
						<input type="radio" id="noticeAtN" value="N" name="noticeAt" <c:if test="${result.noticeAt ne 'Y'}">checked="checked"</c:if>/>
					</td>
				</tr>
				<tr>
					<th scope="row">비공개여부</th>
					<td>
						<label for="noticeAtY">예:  </label>
						<input type="radio" id="othbAtY" value="Y" name="othbcAt" <c:if test="${result.othbcAt eq 'Y'}">checked="cheked"</c:if>/>&nbsp;&nbsp;&nbsp;
						<label for="noticeAtN">아니오:</label>
						<input type="radio" id="othbAtN" value="N" name="othbcAt" <c:if test="${result.othbcAt ne 'Y'}">checked="cheked"</c:if>/>
					</td>
				<tr>
					<th scope="row">작성자ID</th>
					<td>
						<c:out value="${USER_INFO.id}"/>
					</td>
				</tr>
				<tr>
					<th scope="row">내용</th>
					<td>
						<textarea id="boardCn" name="boardCn" rows="15" title="내용입력"><c:out value="${result.boardCn}"/></textarea>
					</td>
				</tr>		
		</tbody>	
	</table>
	<div class="btn-cont ar">
		<c:choose>
			<c:when test="${not empty searchVO.boardId}">
				<c:url var="uptUrl" value="/board/update.do">
					<c:param name="boardId" value="${result.boardId}"/>
				</c:url>
				<a href="${uptUrl}" id="btn-reg" calss="btn">수정</a>
				<c:url var="delUrl" value="/board/delete.do">
					<c:param name="boardId" value="${result.boardId}"/>
				</c:url>
				<a href="${delUrl}" id="btn-del" class="btn"> <i class="ico-del"></i> 삭제</a>
			</c:when>
			<c:otherwise>
				<a href="#none" id="btn-reg" class="btn spot">등록</a>
			</c:otherwise>
			</c:choose>
			<c:url var="listUrl" value="/board/selectList.do"/>
			<a href="${listUrl}" class="btn">취소</a>
         </div>
      </form>
   </div>
</div>
<script>
$(document).ready(function() {
	//게시글 등록
	$("#btn-reg").click(function(){
		$("#frm").submit();
		return false;
	});
	//게시 글 삭제
	$("#btn-del").click(function(){
		if(!confirm("삭제하시겠습니까?")){
			return false;
		}
	});
});

function regist(){
	if(!$("#boardSj").val()) {
		alert("제목을 입력해주세요");
		return false;
	}
}
</script>
</body>
</html>