최종 코드 업데이트
This commit is contained in:
@@ -0,0 +1,195 @@
|
|||||||
|
package kr.itpinc.first.board.controller;
|
||||||
|
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
import kr.itpinc.first.board.service.BoardService;
|
||||||
|
import kr.itpinc.first.common.common.CommandMap;
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
import org.springframework.data.domain.Pageable;
|
||||||
|
import org.springframework.data.domain.Sort;
|
||||||
|
import org.springframework.data.web.PageableDefault;
|
||||||
|
import org.springframework.beans.factory.annotation.Autowired;
|
||||||
|
import org.springframework.stereotype.Controller;
|
||||||
|
import org.springframework.web.bind.annotation.RequestMapping;
|
||||||
|
import org.springframework.web.servlet.ModelAndView;
|
||||||
|
|
||||||
|
//import egovframework.rte.ptl.mvc.tags.ui.pagination.PaginationInfo;
|
||||||
|
//import first.common.common.CommandMap;
|
||||||
|
//import first.sample.service.SampleService;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Controller
|
||||||
|
public class BoardController
|
||||||
|
{
|
||||||
|
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BoardController.class);
|
||||||
|
|
||||||
|
@Autowired
|
||||||
|
private BoardService boardService; //샘플서비스 선언하고
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/openBoardSearch.do")
|
||||||
|
public ModelAndView openBoardSearch(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/boardSearch");
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/openBoardList.do") //경로 맵핑해주고~
|
||||||
|
public ModelAndView openBoardList(
|
||||||
|
@PageableDefault(page = 0, size = 10, sort = "boardId", direction = Sort.Direction.DESC)
|
||||||
|
Pageable pageable,
|
||||||
|
CommandMap commandMap) throws Exception
|
||||||
|
{ //모델뷰 만들고 openSampleBoardList 메서드 만들고
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/boardList"); //모델뷰 객체 선언뒤 jsp파일 지정
|
||||||
|
|
||||||
|
// 이 안에서 pageable 객체를 열어보면 계산이 다 끝나 있습니다.
|
||||||
|
int currentPage = pageable.getPageNumber(); // 현재 페이지 번호 (0부터 시작)
|
||||||
|
int pageSize = pageable.getPageSize(); // 페이지당 데이터 수 (10)
|
||||||
|
long offset = pageable.getOffset(); // DB 쿼리용 시작 위치 (0 * 10 = 0)
|
||||||
|
Map<String, Object> param = commandMap.getMap();
|
||||||
|
param.put("PAGE_INDEX", currentPage);
|
||||||
|
param.put("PAGE_ROW", pageSize);
|
||||||
|
param.put("START", offset);
|
||||||
|
|
||||||
|
|
||||||
|
List<Map<String, Object>> resultMap = boardService.selectBoardList(param);
|
||||||
|
|
||||||
|
|
||||||
|
// 🌟 원인 파악을 위한 디버깅 코드 3줄 추가 🌟
|
||||||
|
System.out.println("넘어온 파라미터: " + commandMap.getMap());
|
||||||
|
System.out.println("DB 조회 건수: " + resultMap.size());
|
||||||
|
if(!resultMap.isEmpty()) {
|
||||||
|
System.out.println("첫 번째 데이터 형태: " + resultMap.get(0));
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
//List<Map<String, Object>> list = sampleService.selectBoardList(commandMap);
|
||||||
|
//앞에서 샘플서비스 선언한것 뒤에 selectBoardList라는 메서드 만들고
|
||||||
|
//mv.addObject("list", list); //앞에서 실행 다하고 list에 담긴건 list라고 선언하고
|
||||||
|
|
||||||
|
//mv.addObject("paginationInfo", (PaginationInfo)resultMap.get("paginationInfo"));
|
||||||
|
log.info(resultMap.toString());
|
||||||
|
mv.addObject("list", resultMap);
|
||||||
|
|
||||||
|
log.info("");
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/testMapArgumentResolver.do")
|
||||||
|
public ModelAndView testMapArgumentResolver(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("");
|
||||||
|
|
||||||
|
if(commandMap.isEmpty() == false)
|
||||||
|
{
|
||||||
|
Iterator<Entry<String,Object>> iterator = commandMap.getMap().entrySet().iterator();
|
||||||
|
Entry<String,Object> entry = null;
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
entry = iterator.next();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/openBoardWrite.do")
|
||||||
|
public ModelAndView openBoardWrite(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/boardWrite"); //JSP 파일 지정
|
||||||
|
System.out.println("========JRebel Test============");
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/Test.do")
|
||||||
|
public ModelAndView Test(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/Test"); //JSP 파일 지정
|
||||||
|
System.out.println("========Test Test============");
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/kk.do")
|
||||||
|
public ModelAndView kk(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/kk"); //JSP 파일 지정
|
||||||
|
System.out.println("========kk Test============");
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/insertBoard.do")
|
||||||
|
public ModelAndView insertBoard(CommandMap commandMap, HttpServletRequest request) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("redirect:/sample/openBoardList.do");
|
||||||
|
|
||||||
|
boardService.insertBoard(commandMap.getMap(), request);
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/openBoardDetail.do")
|
||||||
|
public ModelAndView openBoardDetail(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/boardDetail");
|
||||||
|
|
||||||
|
Map<String,Object> map = boardService.selectBoardDetail(commandMap.getMap());
|
||||||
|
|
||||||
|
mv.addObject("map", map.get("map"));
|
||||||
|
mv.addObject("list", map.get("list")); //요건 첨부파일 목록 부를때 쓸거임
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/openBoardUpdate.do") //수정디테일화면
|
||||||
|
public ModelAndView openBoardUpdate(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("/sample/boardUpdate");
|
||||||
|
|
||||||
|
Map<String, Object> map = boardService.boardUpdate(commandMap.getMap());
|
||||||
|
|
||||||
|
mv.addObject("map", map.get("map")); //내용
|
||||||
|
mv.addObject("list", map.get("list")); //첨부파일
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/updateBoard.do") //수정하기 누르는~~ 혹은 저장하기 누르는~~
|
||||||
|
public ModelAndView updateBoard(CommandMap commandMap, HttpServletRequest request) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("redirect:/sample/openBoardDetail.do");
|
||||||
|
|
||||||
|
boardService.updateBoard(commandMap.getMap(), request);
|
||||||
|
|
||||||
|
mv.addObject("IDX", commandMap.get("IDX"));
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
@RequestMapping(value="/sample/deleteBoard.do")
|
||||||
|
public ModelAndView deleteBoard(CommandMap commandMap) throws Exception
|
||||||
|
{
|
||||||
|
ModelAndView mv = new ModelAndView("redirect:/sample/openBoardList.do");
|
||||||
|
|
||||||
|
boardService.deleteBoard(commandMap.getMap());
|
||||||
|
|
||||||
|
return mv;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,79 @@
|
|||||||
|
package kr.itpinc.first.board.dao;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Repository;
|
||||||
|
|
||||||
|
import kr.itpinc.first.common.dao.AbstractDAO;
|
||||||
|
|
||||||
|
@Repository("boardDAO") //@Repository DAO선언시 주로 사용
|
||||||
|
public class BoardDAO extends AbstractDAO //오 요건 extends로 상속 받았으니 그대로 쓰면됨
|
||||||
|
{
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked") //에러 경고문 필요없음
|
||||||
|
public List<Map<String, Object>> selectBoardList(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
//return (List<Map<String, Object>>) selectList("sample.selectBoardList", map);
|
||||||
|
//첫번째 인자값이 쿼리 이름 -> sample.selectBoardList
|
||||||
|
return (List<Map<String, Object>>) selectPagingList("sample.selectBoardList", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertBoard(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
insert("sample.insertBoard", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void insertFile(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
insert("sample.insertFile", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
/*public void updateHitCnt(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
update("sample.updateHitCnt", map);
|
||||||
|
}*/
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Object> selectBoardDetail(Map<String, Object> map) throws Exception{
|
||||||
|
return (Map<String, Object>) selectOne("sample.selectBoardDetail", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public List<Map<String, Object>> selectFileList(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
return (List<Map<String, Object>>) selectList("sample.selectFileList", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
public Map<String, Object> boardUpdate(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
return (Map<String, Object>) selectOne("sample.boardUpdate", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateBoard(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
update("sample.updateBoard", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteBoard(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
delete("sample.deleteBoard", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateHitCnt(Map<String, Object> map)
|
||||||
|
{
|
||||||
|
update("sample.updateHitCnt", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void deleteFileList(Map<String, Object> map)
|
||||||
|
{
|
||||||
|
update("sample.deleteFileList", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void updateFile(Map<String, Object> map)
|
||||||
|
{
|
||||||
|
update("sample.updateFile", map);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,26 @@
|
|||||||
|
package kr.itpinc.first.board.service;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
public interface BoardService {
|
||||||
|
|
||||||
|
List<Map<String, Object>> selectBoardList(Map<String, Object> map) throws Exception;
|
||||||
|
|
||||||
|
void insertBoard(Map<String, Object> map, HttpServletRequest request) throws Exception;
|
||||||
|
|
||||||
|
Map<String, Object> selectBoardDetail(Map<String, Object> map) throws Exception;
|
||||||
|
|
||||||
|
Map<String, Object> boardUpdate(Map<String, Object> map) throws Exception;
|
||||||
|
|
||||||
|
void updateBoard(Map<String, Object> map, HttpServletRequest request) throws Exception;
|
||||||
|
|
||||||
|
void deleteBoard(Map<String, Object> map) throws Exception;
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
@@ -0,0 +1,124 @@
|
|||||||
|
package kr.itpinc.first.board.service;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.Iterator;
|
||||||
|
import java.util.List;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
import jakarta.annotation.Resource;
|
||||||
|
import jakarta.servlet.http.HttpServletRequest;
|
||||||
|
|
||||||
|
import org.springframework.stereotype.Service;
|
||||||
|
import org.springframework.web.multipart.MultipartFile;
|
||||||
|
import org.springframework.web.multipart.MultipartHttpServletRequest;
|
||||||
|
|
||||||
|
import kr.itpinc.first.common.util.FileUtils;
|
||||||
|
import kr.itpinc.first.board.controller.BoardController;
|
||||||
|
import kr.itpinc.first.board.dao.BoardDAO;
|
||||||
|
|
||||||
|
import lombok.extern.slf4j.Slf4j;
|
||||||
|
|
||||||
|
@Slf4j
|
||||||
|
@Service("boardService")
|
||||||
|
public class BoardServiceImpl implements BoardService //인터페이스 상속시 implements
|
||||||
|
{ //SampleSeriveImpl 클래스 선언하는데 SampleSerive
|
||||||
|
|
||||||
|
private static final org.slf4j.Logger log = org.slf4j.LoggerFactory.getLogger(BoardServiceImpl.class);
|
||||||
|
|
||||||
|
@Resource(name="fileUtils")
|
||||||
|
private FileUtils fileUtils;
|
||||||
|
|
||||||
|
@Resource(name="boardDAO")
|
||||||
|
private BoardDAO boardDAO; //SampleDAO 선언해주고
|
||||||
|
|
||||||
|
@Override //implements로 상속 받았으니 @Override로 재 정의해줌(SampleService에서 정의한놈)
|
||||||
|
public List<Map<String, Object>> selectBoardList(Map<String, Object> map) throws Exception {
|
||||||
|
|
||||||
|
return boardDAO.selectBoardList(map);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void insertBoard(Map<String, Object> map, HttpServletRequest request) throws Exception
|
||||||
|
{
|
||||||
|
boardDAO.insertBoard(map);
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = fileUtils.parseInsertFileInfo(map, request);
|
||||||
|
for(int i=0,size=list.size();i<size;i++)
|
||||||
|
{
|
||||||
|
boardDAO.insertFile(list.get(i));
|
||||||
|
}
|
||||||
|
|
||||||
|
MultipartHttpServletRequest multipartHttpServletRequest = (MultipartHttpServletRequest)request;
|
||||||
|
Iterator<String> iterator = multipartHttpServletRequest.getFileNames();
|
||||||
|
MultipartFile multipartFile = null;
|
||||||
|
|
||||||
|
while(iterator.hasNext())
|
||||||
|
{
|
||||||
|
multipartFile = multipartHttpServletRequest.getFile(iterator.next());
|
||||||
|
|
||||||
|
if(multipartFile.isEmpty() == false)
|
||||||
|
{
|
||||||
|
log.debug("--------------file start------------");
|
||||||
|
log.debug("name :" + multipartFile.getName());
|
||||||
|
log.debug("filename :" + multipartFile.getOriginalFilename());
|
||||||
|
log.debug("size :" + multipartFile.getSize());
|
||||||
|
log.debug("--------------file end--------------\n");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> selectBoardDetail(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
boardDAO.updateHitCnt(map);
|
||||||
|
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
Map<String, Object> tempMap = boardDAO.selectBoardDetail(map);
|
||||||
|
resultMap.put("map", tempMap);
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = boardDAO.selectFileList(map);
|
||||||
|
resultMap.put("list", list);
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Map<String, Object> boardUpdate(Map<String, Object> map) throws Exception
|
||||||
|
{
|
||||||
|
Map<String, Object> resultMap = new HashMap<String, Object>();
|
||||||
|
Map<String, Object> tempMap = boardDAO.boardUpdate(map);
|
||||||
|
resultMap.put("map", tempMap);
|
||||||
|
|
||||||
|
List<Map<String, Object>> list = boardDAO.selectFileList(map);
|
||||||
|
resultMap.put("list", list);
|
||||||
|
|
||||||
|
return resultMap;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void updateBoard(Map<String, Object> map, HttpServletRequest request) throws Exception
|
||||||
|
{
|
||||||
|
boardDAO.updateBoard(map); //기존 글만 수정(업데이트)
|
||||||
|
|
||||||
|
boardDAO.deleteFileList(map); // (DEL_GB = 'Y') 로 처리하는 부분
|
||||||
|
List<Map<String, Object>> list = fileUtils.parseInsertFileInfo(map, request);
|
||||||
|
Map<String, Object> tempMap = null;
|
||||||
|
for(int i=0,size=list.size();i<size;i++)
|
||||||
|
{
|
||||||
|
tempMap = list.get(i);
|
||||||
|
if(tempMap.get("IS_NEW").equals("Y"))
|
||||||
|
{
|
||||||
|
boardDAO.insertFile(tempMap);
|
||||||
|
}else{
|
||||||
|
boardDAO.updateFile(tempMap);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void deleteBoard(Map<String, Object> map) throws Exception {
|
||||||
|
|
||||||
|
boardDAO.deleteBoard(map);
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -0,0 +1,188 @@
|
|||||||
|
<?xml version="1.0" encoding="UTF-8"?>
|
||||||
|
<!DOCTYPE mapper PUBLIC "-//mybatis.org//DTD Mapper 3.0//EN" "http://mybatis.org/dtd/mybatis-3-mapper.dtd">
|
||||||
|
|
||||||
|
<mapper namespace="sample">
|
||||||
|
<select id="selectBoardList" parameterType="hashmap" resultType="hashmap">
|
||||||
|
<include refid="common.pagingPre"/>
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
ROW_NUMBER() OVER (ORDER BY IDX DESC) RNUM,
|
||||||
|
IDX,
|
||||||
|
TITLE,
|
||||||
|
HIT_CNT,
|
||||||
|
CREA_DTM
|
||||||
|
FROM
|
||||||
|
TB_BOARD
|
||||||
|
WHERE
|
||||||
|
DEL_GB = 'N'
|
||||||
|
]]>
|
||||||
|
<include refid="common.pagingPost"/>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<insert id="insertBoard" parameterType="hashmap" useGeneratedKeys="true" keyProperty="IDX">
|
||||||
|
<selectKey keyProperty="IDX" resultType="string" order="BEFORE">
|
||||||
|
SELECT SEQ_TB_BOARD_IDX.NEXTVAL FROM DUAL
|
||||||
|
</selectKey>
|
||||||
|
<![CDATA[
|
||||||
|
INSERT INTO TB_BOARD
|
||||||
|
(
|
||||||
|
IDX,
|
||||||
|
TITLE,
|
||||||
|
CONTENTS,
|
||||||
|
HIT_CNT,
|
||||||
|
DEL_GB,
|
||||||
|
CREA_DTM,
|
||||||
|
CREA_ID
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
#{IDX},
|
||||||
|
#{TITLE,jdbcType=VARCHAR},
|
||||||
|
#{CONTENTS,jdbcType=VARCHAR},
|
||||||
|
0,
|
||||||
|
'N',
|
||||||
|
SYSDATE,
|
||||||
|
'Admin'
|
||||||
|
)
|
||||||
|
]]>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<!-- <update id="updateHitCnt" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_BOARD
|
||||||
|
SET
|
||||||
|
HIT_CNT = NVL(HIT_CNT,0)+1
|
||||||
|
WHERE
|
||||||
|
IDX=#{IDX]
|
||||||
|
]]>
|
||||||
|
</update> --><!-- HIT_CNT 가 null일경우, 두번째 반환 -->
|
||||||
|
|
||||||
|
<update id="updateHitCnt" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_BOARD
|
||||||
|
SET HIT_CNT = HIT_CNT + 1
|
||||||
|
WHERE IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<select id="selectBoardDetail" parameterType="hashmap" resultType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
IDX,
|
||||||
|
HIT_CNT,
|
||||||
|
CREA_ID,
|
||||||
|
CREA_DTM,
|
||||||
|
TITLE,
|
||||||
|
CONTENTS
|
||||||
|
FROM
|
||||||
|
TB_BOARD
|
||||||
|
WHERE
|
||||||
|
IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<select id="boardUpdate" parameterType="hashmap" resultType="hashmap">
|
||||||
|
<!-- <![CDATA[
|
||||||
|
UPDATE TB_BOARD
|
||||||
|
SET
|
||||||
|
TITLE = #{TITLE},
|
||||||
|
CONTENTS = #{CONTENTS}
|
||||||
|
WHERE
|
||||||
|
IDX = #{IDX}
|
||||||
|
]]> -->
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
IDX,
|
||||||
|
HIT_CNT,
|
||||||
|
CREA_ID,
|
||||||
|
CREA_DTM,
|
||||||
|
TITLE,
|
||||||
|
CONTENTS
|
||||||
|
FROM
|
||||||
|
TB_BOARD
|
||||||
|
WHERE IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="updateBoard" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_BOARD
|
||||||
|
SET TITLE=#{TITLE},
|
||||||
|
CONTENTS=#{CONTENTS}
|
||||||
|
WHERE
|
||||||
|
IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<delete id="deleteBoard" parameterType="hashmap">
|
||||||
|
<!-- <![CDATA[
|
||||||
|
DELETE FROM
|
||||||
|
TB_BOARD
|
||||||
|
WHERE IDX=#{IDX}
|
||||||
|
]]> -->
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_BOARD
|
||||||
|
SET DEL_GB = 'Y'
|
||||||
|
WHERE IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
|
||||||
|
</delete>
|
||||||
|
|
||||||
|
<insert id="insertFile" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
INSERT INTO TB_FILE
|
||||||
|
(
|
||||||
|
IDX,
|
||||||
|
BOARD_IDX,
|
||||||
|
ORIGINAL_FILE_NAME,
|
||||||
|
STORED_FILE_NAME,
|
||||||
|
FILE_SIZE,
|
||||||
|
CREA_ID
|
||||||
|
)
|
||||||
|
VALUES
|
||||||
|
(
|
||||||
|
SEQ_TB_FILE_IDX.NEXTVAL,
|
||||||
|
#{BOARD_IDX},
|
||||||
|
#{ORIGINAL_FILE_NAME},
|
||||||
|
#{STORED_FILE_NAME},
|
||||||
|
#{FILE_SIZE},
|
||||||
|
'Admin'
|
||||||
|
)
|
||||||
|
]]>
|
||||||
|
</insert>
|
||||||
|
|
||||||
|
<select id="selectFileList" parameterType="hashmap" resultType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
SELECT
|
||||||
|
IDX,
|
||||||
|
ORIGINAL_FILE_NAME,
|
||||||
|
ROUND(FILE_SIZE/1024,1) AS FILE_SIZE
|
||||||
|
FROM
|
||||||
|
TB_FILE
|
||||||
|
WHERE
|
||||||
|
BOARD_IDX=#{IDX}
|
||||||
|
AND DEL_GB='N'
|
||||||
|
]]>
|
||||||
|
</select>
|
||||||
|
|
||||||
|
<update id="deleteFileList" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_FILE SET
|
||||||
|
DEL_GB='Y'
|
||||||
|
WHERE
|
||||||
|
BOARD_IDX=#{IDX}
|
||||||
|
]]>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<update id="updateFile" parameterType="hashmap">
|
||||||
|
<![CDATA[
|
||||||
|
UPDATE TB_FILE SET
|
||||||
|
DEL_GB='N'
|
||||||
|
WHERE
|
||||||
|
IDX=#{FILE_IDX}
|
||||||
|
]]>
|
||||||
|
</update>
|
||||||
|
|
||||||
|
<!-- <![CDATA...요건 혹시모를 쿼리문에 <,> 등의 기호가 들어갈때를 대비하여 씀 -->
|
||||||
|
</mapper>
|
||||||
@@ -0,0 +1,2 @@
|
|||||||
|
<%@ page pageEncoding="UTF-8"%>
|
||||||
|
<form id="commonForm" name="commonForm"></form>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<%@ page pageEncoding="UTF-8"%>
|
||||||
|
|
||||||
|
<meta charset="UTF-8">
|
||||||
|
<meta http-equiv="X-UA-Compatible" content="IE=edge"/>
|
||||||
|
<title>bloggers</title>
|
||||||
|
|
||||||
|
<%@ taglib prefix="c" uri="jakarta.tags.core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="jakarta.tags.functions" %>
|
||||||
|
<%@ taglib prefix="fmt" uri="jakarta.tags.fmt" %>
|
||||||
|
|
||||||
|
<link rel="stylesheet" type="text/css" href="<c:url value='/css/ui.css'/>" />
|
||||||
|
|
||||||
|
<!-- jQuery -->
|
||||||
|
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.11.2/jquery.min.js"></script>
|
||||||
|
<script src="<c:url value='/js/common.js'/>" charset="UTF-8"></script>
|
||||||
@@ -0,0 +1,94 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
|
||||||
|
pageEncoding="EUC-KR"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %>
|
||||||
|
<%@ taglib prefix="fn" uri="http://java.sun.com/jsp/jstl/functions" %>
|
||||||
|
<%@ include file ="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>게시판 목록</h2>
|
||||||
|
<table class="board_list">
|
||||||
|
<colgroup>
|
||||||
|
<col width="10%"/>
|
||||||
|
<col width="50"/>
|
||||||
|
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">글번호</th>
|
||||||
|
<th scope="col">제목</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${fn:length(list) > 0}"> <!-- boolean -->
|
||||||
|
<c:forEach items="${list }" var="row" varStatus="status">
|
||||||
|
<tr>
|
||||||
|
<td>${row.IDX }</td>
|
||||||
|
<td class="title">
|
||||||
|
<a href="#this" name="title">${row.TITLE }</a>
|
||||||
|
<input type="hidden" id="IDX" value="${row.IDX }">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">조회된 결과가 없습니다.</td>
|
||||||
|
</tr>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<c:if test="${not empty paginationInfo }">
|
||||||
|
<ui:pagination paginationInfo = "${paginationInfo }" type="text" jsFunction="fn_search"/>
|
||||||
|
</c:if>
|
||||||
|
<input type="hidden" id="currentPageNo" name="currentPageNo"/>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<a href="#this" class="btn" id="write">글쓰기</a>
|
||||||
|
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#write").on("click", function(e){ //글쓰기 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardWrite();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a[name='title']").on("click", function(e){ //제목
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardDetail($(this)); //$(this)의미 : jQuery <a 태그의미
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function fn_openBoardWrite(){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardWrite.do' />");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_openBoardDetail(obj){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardDetail.do' />");
|
||||||
|
comSubmit.addParam("IDX", obj.parent().find("#IDX").val()); // key와 value값
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_search(pageNo)
|
||||||
|
{
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardList.do'/>");
|
||||||
|
comSubmit.addParam("currentPageNo", pageNo);
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,24 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
|
||||||
|
pageEncoding="EUC-KR"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
|
||||||
|
<script src="http://ajax.googleapis.com/ajax/libs/1/jquery.min.js"></script>
|
||||||
|
<script>
|
||||||
|
$(document).ready(function(){
|
||||||
|
var name = $('#name');
|
||||||
|
var greeting = $('#greeting');
|
||||||
|
|
||||||
|
name.bind('keydown', function(){
|
||||||
|
setTimeout(greeting.text('HELLO,' + name.val() + '!!!'),0);
|
||||||
|
});
|
||||||
|
});
|
||||||
|
</script>
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<input id="name" value=""/>
|
||||||
|
<p id="greeting"></p>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,103 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<%@ include file="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<table class="board_view">
|
||||||
|
<colgroup>
|
||||||
|
<col width="15%"/>
|
||||||
|
<col width="35%"/>
|
||||||
|
<col width="15%"/>
|
||||||
|
<col width="35%"/>
|
||||||
|
</colgroup>
|
||||||
|
<caption>게시글 상세</caption>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">글 번호</th>
|
||||||
|
<td>${map.IDX }</td>
|
||||||
|
<th scope="row">조회수</th>
|
||||||
|
<td>${map.HIT_CNT }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">작성자</th>
|
||||||
|
<td>${map.CREA_ID }</td>
|
||||||
|
<th scope="row">작성시간</th>
|
||||||
|
<td>${map.CREA_DTM }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">제목</th>
|
||||||
|
<td colspan="3">${map.TITLE }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">${map.CONTENTS }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">첨부파일</th>
|
||||||
|
<td colspan="3">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${fn:length(list) >0 }"> <!-- boolean -->
|
||||||
|
<c:forEach var="row" items="${list}">
|
||||||
|
<input type="hidden" id="IDX" value="${row.IDX }">
|
||||||
|
<a href="#this" name="file">${row.ORIGINAL_FILE_NAME }</a>
|
||||||
|
(${row.FILE_SIZE }kb)
|
||||||
|
</c:forEach>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>첨부된 파일이 없습니다.!</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<a href="#this" class="btn" id="list">목록으로</a>
|
||||||
|
<a href="#this" class="btn" id="update">수정하기</a>
|
||||||
|
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#list").on("click", function(e){ //목록으로 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardList();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#update").on("click", function(e){ //수정하기 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardUpdate();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a[name='file']").on("click", function(e){ //파일이름
|
||||||
|
e.preventDefault();
|
||||||
|
fn_downloadFile($(this));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fn_openBoardList(){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardList.do' />");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_openBoardUpdate(){
|
||||||
|
var idx = "${map.IDX}";
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardUpdate.do' />");
|
||||||
|
comSubmit.addParam("IDX", idx);
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_downloadFile(obj)
|
||||||
|
{
|
||||||
|
var idx = obj.parent().find("#IDX").val();
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/common/downloadFile.do'/>");
|
||||||
|
comSubmit.addParam("IDX", idx);
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,98 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<%@ include file ="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h2>게시판 목록</h2>
|
||||||
|
<table class="board_list">
|
||||||
|
<colgroup>
|
||||||
|
<col width="10%"/>
|
||||||
|
<col width="*"/>
|
||||||
|
<col width="15%"/>
|
||||||
|
<col width="20%"/>
|
||||||
|
</colgroup>
|
||||||
|
<thead>
|
||||||
|
<tr>
|
||||||
|
<th scope="col">글번호</th>
|
||||||
|
<th scope="col">제목</th>
|
||||||
|
<th scope="col">조회수</th>
|
||||||
|
<th scope="col">작성일</th>
|
||||||
|
</tr>
|
||||||
|
</thead>
|
||||||
|
<tbody>
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${fn:length(list) > 0}"> <!-- boolean -->
|
||||||
|
<c:forEach items="${list }" var="row" varStatus="status">
|
||||||
|
<tr>
|
||||||
|
<td>${row.IDX }</td>
|
||||||
|
<td class="title">
|
||||||
|
<a href="#this" name="title">${row.TITLE }</a>
|
||||||
|
<input type="hidden" id="IDX" value="${row.IDX }">
|
||||||
|
</td>
|
||||||
|
<td>${row.HIT_CNT }</td>
|
||||||
|
<td>${row.CREA_DTM }</td>
|
||||||
|
</tr>
|
||||||
|
</c:forEach>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4">조회된 결과가 없습니다.</td>
|
||||||
|
</tr>
|
||||||
|
</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
|
||||||
|
<c:if test="${not empty paginationInfo }">
|
||||||
|
<ui:pagination paginationInfo = "${paginationInfo }" type="text" jsFunction="fn_search"/>
|
||||||
|
</c:if>
|
||||||
|
<input type="hidden" id="currentPageNo" name="currentPageNo"/>
|
||||||
|
|
||||||
|
<br/>
|
||||||
|
<a href="#this" class="btn" id="write">글쓰기</a>
|
||||||
|
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#write").on("click", function(e){ //글쓰기 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardWrite();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a[name='title']").on("click", function(e){ //제목
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardDetail($(this)); //$(this)의미 : jQuery <a 태그의미
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
|
||||||
|
function fn_openBoardWrite(){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardWrite.do' />");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_openBoardDetail(obj){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardDetail.do' />");
|
||||||
|
comSubmit.addParam("IDX", obj.parent().find("#IDX").val()); // key와 value값
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_search(pageNo)
|
||||||
|
{
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardList.do'/>");
|
||||||
|
comSubmit.addParam("currentPageNo", pageNo);
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,13 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<%@ include file="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
HI~
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,164 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
<%@ include file="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="frm" name="frm" enctype="multipart/form-data">
|
||||||
|
<table class="board_view">
|
||||||
|
<colgroup>
|
||||||
|
<col width="15%"/>
|
||||||
|
<col width="35%"/>
|
||||||
|
<col width="15%"/>
|
||||||
|
<col width="35%"/>
|
||||||
|
</colgroup>
|
||||||
|
<caption>게시글 상세</caption>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">글 번호</th>
|
||||||
|
<td>
|
||||||
|
${map.IDX }
|
||||||
|
<input type="hidden" id="IDX" name="IDX" value="${map.IDX }">
|
||||||
|
</td>
|
||||||
|
<th scope="row">조회수</th>
|
||||||
|
<td>${map.HIT_CNT }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">작성자</th>
|
||||||
|
<td>${map.CREA_ID }</td>
|
||||||
|
<th scope="row">작성시간</th>
|
||||||
|
<td>${map.CREA_DTM }</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">제목</th>
|
||||||
|
<td colspan="3">
|
||||||
|
<input type="text" id="TITLE" name="TITLE" class="wdp_90" value="${map.TITLE }">
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="4" class="view_text">
|
||||||
|
<textarea rows="20" cols="100" title="내용" id="CONTENTS" name="CONTENTS">${map.CONTENTS }</textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">첨부파일</th>
|
||||||
|
<td colspan="3">
|
||||||
|
<div id="fileDiv">
|
||||||
|
<c:choose>
|
||||||
|
<c:when test="${fn:length(list)>0 }">
|
||||||
|
<c:forEach var="row" items="${list }" varStatus="var">
|
||||||
|
<p>
|
||||||
|
<input type="hidden" id="IDX" name="IDX_${var.index }" value="${row.IDX }">
|
||||||
|
<a href="#this" id="name_${var.index }" name="name_${var.index }">${row.ORIGINAL_FILE_NAME }</a>
|
||||||
|
<input type="file" id="file_${var.index }" name="file_${var.index }">
|
||||||
|
(${row.FILE_SIZE }kb)
|
||||||
|
<a href="#this" class="btn" id="delete_${var.index }" name="delete_${var.index }">삭제</a>
|
||||||
|
</p>
|
||||||
|
</c:forEach>
|
||||||
|
</c:when>
|
||||||
|
<c:otherwise>첨부된 파일이 없습니다!</c:otherwise>
|
||||||
|
</c:choose>
|
||||||
|
</div>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
</form>
|
||||||
|
<a href="#this" class="btn" id="addFile">파일추가</a>
|
||||||
|
<a href="#this" class="btn" id="list">목록으로</a>
|
||||||
|
<a href="#this" class="btn" id="update">저장하기</a>
|
||||||
|
<a href="#this" class="btn" id="delete">삭제하기</a>
|
||||||
|
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
|
||||||
|
<script type="text/javascript">
|
||||||
|
|
||||||
|
var gfv_count = "${fn:length(list)+1}";
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
|
||||||
|
$("#list").on("click",function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardList();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#update").on("click",function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
fn_updateBoard();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#delete").on("click",function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
fn_deleteBoard();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#addFile").on("click", function(e){ //파일 추가
|
||||||
|
e.preventDefault();
|
||||||
|
fn_addFile();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a[name^='delete']").on("click", function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
fn_deleteFile($(this));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fn_openBoardList()
|
||||||
|
{
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardList.do'/>");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_updateBoard()
|
||||||
|
{
|
||||||
|
var comSubmit = new ComSubmit("frm");
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/updateBoard.do'/>");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_deleteBoard()
|
||||||
|
{
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/deleteBoard.do'/>");
|
||||||
|
comSubmit.addParam("IDX",$("#IDX").val());
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_addFile()
|
||||||
|
{
|
||||||
|
var str = "<p><input type='file' id='file_"+(gfv_count)+"' name='file_"+(gfv_count)+"'>"+
|
||||||
|
"<a href='#this' class='btn' id='delete_"+(gfv_count)+"' name='delete_"+(gfv_count)+"'>삭제</a></p>";
|
||||||
|
|
||||||
|
$("#fileDiv").append(str);
|
||||||
|
$("#delete_"+(gfv_count++)).on("click", function(e){
|
||||||
|
e.preventDefault();
|
||||||
|
fn_deleteFile($(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
//boardWrite.jsp 와 비교
|
||||||
|
|
||||||
|
/* function fn_addFile(){
|
||||||
|
var str = "<p><input type='file' name='file_"+(gfv_count++)+"'><a href='#this' class='btn' name='delete'>삭제</a></p>";
|
||||||
|
$("#fileDiv").append(str);
|
||||||
|
$("a[name='delete']").on("click", function(e){ //삭제 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_deleteFile($(this));
|
||||||
|
});
|
||||||
|
} */
|
||||||
|
|
||||||
|
|
||||||
|
function fn_deleteFile(obj)
|
||||||
|
{
|
||||||
|
obj.parent().remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
</script>
|
||||||
|
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,97 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=UTF-8"
|
||||||
|
pageEncoding="UTF-8"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html lang="ko">
|
||||||
|
<head>
|
||||||
|
<%@ include file="/WEB-INF/include/include-header.jspf" %>
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<form id="frm" name="frm" enctype="multipart/form-data">
|
||||||
|
<table class="board_view">
|
||||||
|
<colgroup>
|
||||||
|
<col width="15%">
|
||||||
|
<col width="*"/>
|
||||||
|
</colgroup>
|
||||||
|
<caption>게시글 작성</caption>
|
||||||
|
<tbody>
|
||||||
|
<tr>
|
||||||
|
<th scope="row">제목</th>
|
||||||
|
<td><input type="text" id="TITLE" name="TITLE" class="wdp_90"></input></td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td colspan="2" class="view_text">
|
||||||
|
<textarea rows="20" cols="80" title="내용" id="CONTENTS" name="CONTENTS"></textarea>
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
</tbody>
|
||||||
|
</table>
|
||||||
|
<!-- <input type="file" name="file"><br/><br/> -->
|
||||||
|
|
||||||
|
<div id="fileDiv">
|
||||||
|
<p>
|
||||||
|
<input type="file" id="file" name="file_0">
|
||||||
|
<a href="#this" class="btn" id="delete" name="delete">삭제</a>
|
||||||
|
</p>
|
||||||
|
</div>
|
||||||
|
<br/><br/>
|
||||||
|
<a href="#this" class="btn" id="addFile">파일추가</a>
|
||||||
|
<a href="#this" class="btn" id="write">작성하기</a>
|
||||||
|
<a href="#this" class="btn" id="list">목록으로</a>
|
||||||
|
</form>
|
||||||
|
|
||||||
|
<%@ include file="/WEB-INF/include/include-body.jspf" %>
|
||||||
|
<script type="text/javascript">
|
||||||
|
var gfv_count = 1;
|
||||||
|
|
||||||
|
$(document).ready(function(){
|
||||||
|
$("#list").on("click", function(e){ //목록으로 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_openBoardList();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#write").on("click", function(e){ //작성하기 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_insertBoard();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("#addFile").on("click", function(e){ //파일추가하기
|
||||||
|
e.preventDefault();
|
||||||
|
fn_addFile();
|
||||||
|
});
|
||||||
|
|
||||||
|
$("a[name='delete']").on("click", function(e){ //추가한 파일 삭제하기
|
||||||
|
e.prevnetDefault();
|
||||||
|
fn_deleteFile($(this));
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
function fn_openBoardList(){
|
||||||
|
var comSubmit = new ComSubmit();
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/openBoardList.do' />");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_insertBoard(){
|
||||||
|
var comSubmit = new ComSubmit("frm");
|
||||||
|
comSubmit.setUrl("<c:url value='/sample/insertBoard.do' />");
|
||||||
|
comSubmit.submit();
|
||||||
|
}
|
||||||
|
|
||||||
|
function fn_addFile(){
|
||||||
|
var str = "<p><input type='file' name='file_"+(gfv_count++)+"'><a href='#this' class='btn' name='delete'>삭제</a></p>";
|
||||||
|
$("#fileDiv").append(str);
|
||||||
|
$("a[name='delete']").on("click", function(e){ //삭제 버튼
|
||||||
|
e.preventDefault();
|
||||||
|
fn_deleteFile($(this));
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
function fn_deleteFile(obj)
|
||||||
|
{
|
||||||
|
obj.parent().remove(); //<p>태그 삭제
|
||||||
|
}
|
||||||
|
</script>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
|
||||||
|
pageEncoding="EUC-KR"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
kkkk
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,15 @@
|
|||||||
|
<%@ 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" %>
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<title>Home</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<h1>
|
||||||
|
Hello world!
|
||||||
|
</h1>
|
||||||
|
|
||||||
|
<P> The time on the server is ${serverTime}. </P>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,23 @@
|
|||||||
|
@CHARSET "UTF-8";
|
||||||
|
|
||||||
|
a:link, a:visited {text-decoration: none; color: #656565;}
|
||||||
|
|
||||||
|
.board_list {width:100%;border-top:2px solid #252525;border-bottom:1px solid #ccc}
|
||||||
|
.board_list thead th:first-child{background-image:none}
|
||||||
|
.board_list thead th {border-bottom:1px solid #ccc;padding:12px 0 13px 0;color:#3b3a3a;vertical-align:middle}
|
||||||
|
.board_list tbody td {border-top:1px solid #ccc;padding:10px 0;text-align:center;vertical-align:middle}
|
||||||
|
.board_list tbody tr:first-child td {border:none}
|
||||||
|
.board_list tbody td.title {text-align:left; padding-left:20px}
|
||||||
|
.board_list tbody td a {display:inline-block}
|
||||||
|
|
||||||
|
.board_view {width:30%;border-top:2px solid #252525;border-bottom:1px solid #ccc}
|
||||||
|
.board_view tbody th {text-align:left;background:#f7f7f7;color:#3b3a3a}
|
||||||
|
.board_view tbody th.list_tit {font-size:13px;color:#000;letter-spacing:0.1px}
|
||||||
|
.board_view tbody .no_line_b th, .board_view tbody .no_line_b td {border-bottom:none}
|
||||||
|
.board_view tbody th, .board_view tbody td {padding:15px 0 16px 16px;border-bottom:1px solid #ccc}
|
||||||
|
.board_view tbody td.view_text {border-top:1px solid #ccc; border-bottom:1px solid #ccc;padding:45px 18px 45px 18px}
|
||||||
|
.board_view tbody th.th_file {padding:0 0 0 15px; vertical-align:middle}
|
||||||
|
|
||||||
|
.wdp_90 {width:60%}
|
||||||
|
.btn {border-radius:3px;padding:5px 11px;color:#fff !important; display:inline-block; background-color:#6b9ab8; border:1px solid #56819d;vertical-align:middle}
|
||||||
|
.pad_5 {padding: 5px}
|
||||||
@@ -0,0 +1,12 @@
|
|||||||
|
<%@ page language="java" contentType="text/html; charset=EUC-KR"
|
||||||
|
pageEncoding="EUC-KR"%>
|
||||||
|
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
|
||||||
|
<html>
|
||||||
|
<head>
|
||||||
|
<meta http-equiv="Content-Type" content="text/html; charset=EUC-KR">
|
||||||
|
<title>Insert title here</title>
|
||||||
|
</head>
|
||||||
|
<body>
|
||||||
|
<jsp:forward page="/sample/openSampleList.do"/>
|
||||||
|
</body>
|
||||||
|
</html>
|
||||||
@@ -0,0 +1,179 @@
|
|||||||
|
function gfn_isNull(str) {
|
||||||
|
if (str == null) return true;
|
||||||
|
if (str == "NaN") return true;
|
||||||
|
if (new String(str).valueOf() == "undefined") return true;
|
||||||
|
var chkStr = new String(str);
|
||||||
|
if( chkStr.valueOf() == "undefined" ) return true;
|
||||||
|
if (chkStr == null) return true;
|
||||||
|
if (chkStr.toString().length == 0 ) return true;
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 공통 서브밋 객체 (Target/Popup 대응 버전)
|
||||||
|
*/
|
||||||
|
function ComSubmit(opt_formId) {
|
||||||
|
this.formId = (typeof opt_formId === "undefined" || opt_formId === null || opt_formId === "") ? "commonForm" : opt_formId;
|
||||||
|
this.url = "";
|
||||||
|
this.target = "_self"; // 기본값은 현재 창
|
||||||
|
|
||||||
|
var $targetForm = $("#" + this.formId);
|
||||||
|
|
||||||
|
// [1] 초기화: commonForm일 경우 내부를 비우고 target도 기본값으로 리셋
|
||||||
|
if ($targetForm.length > 0 && this.formId === "commonForm") {
|
||||||
|
$targetForm.empty();
|
||||||
|
$targetForm.attr("target", "_self"); // 이전 타겟 설정 제거
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setUrl = function setUrl(url) {
|
||||||
|
this.url = url;
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [2] 타겟 설정 (팝업창 이름이나 _blank 등)
|
||||||
|
*/
|
||||||
|
this.setTarget = function setTarget(target) {
|
||||||
|
this.target = target;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.addParam = function addParam(key, value) {
|
||||||
|
if ($targetForm.length === 0) return;
|
||||||
|
var $existingParam = $targetForm.find("input[name='" + key + "']");
|
||||||
|
|
||||||
|
if ($existingParam.length > 0) {
|
||||||
|
$existingParam.val(value);
|
||||||
|
} else {
|
||||||
|
var inputHtml = $("<input>", { type: "hidden", name: key, id: key, value: value });
|
||||||
|
$targetForm.append(inputHtml);
|
||||||
|
}
|
||||||
|
};
|
||||||
|
|
||||||
|
/**
|
||||||
|
* [3] 서버 전송
|
||||||
|
*/
|
||||||
|
this.submit = function submit() {
|
||||||
|
if ($targetForm.length === 0) return;
|
||||||
|
|
||||||
|
var frm = $targetForm[0];
|
||||||
|
if (!this.url) {
|
||||||
|
alert("전송할 URL이 설정되지 않았습니다.");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
frm.action = this.url;
|
||||||
|
frm.method = "post";
|
||||||
|
frm.target = this.target; // 설정된 타겟 적용
|
||||||
|
frm.submit();
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
var gfv_ajaxCallback = "";
|
||||||
|
|
||||||
|
function ComAjax(opt_formId)
|
||||||
|
{
|
||||||
|
this.url = "";
|
||||||
|
this.formId = gfn_isNull(opt_formId) == true?"commonForm":opt_formId;
|
||||||
|
this.param = "";
|
||||||
|
|
||||||
|
if(this.formId == "commonForm")
|
||||||
|
{
|
||||||
|
var frm = $("#commonForm");
|
||||||
|
if(frm.length>0){
|
||||||
|
frm.remove();
|
||||||
|
}
|
||||||
|
|
||||||
|
var str = "<form id='commonForm' name='commonForm'></form>";
|
||||||
|
$('body').append(str);
|
||||||
|
}
|
||||||
|
|
||||||
|
this.setUrl = function setUrl(url)
|
||||||
|
{
|
||||||
|
this.url = url;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.setCallback = function setCallback(callBack)
|
||||||
|
{
|
||||||
|
fv_ajaxCallback = callBack;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.addParam = function addParam(key, value)
|
||||||
|
{
|
||||||
|
this.param = this.param + "&" + key + "=" + value;
|
||||||
|
};
|
||||||
|
|
||||||
|
this.ajax = function ajax()
|
||||||
|
{
|
||||||
|
if(this.formId != "commonForm"){
|
||||||
|
this.param += "&" + $("#" + this.formId).serialize();
|
||||||
|
}
|
||||||
|
$.ajax({
|
||||||
|
url : this.url,
|
||||||
|
type : "post",
|
||||||
|
data : this.param,
|
||||||
|
async : false,
|
||||||
|
success : function(data, status){
|
||||||
|
if(typeof(fv_ajaxCallback) == "function"){
|
||||||
|
fv_ajaxCallback(data);
|
||||||
|
}else{
|
||||||
|
eval(fv_ajaxCallback + "(data);");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
});
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
//페이징 태그부분
|
||||||
|
/*
|
||||||
|
* divId : 페이징 태그가 그려질 div
|
||||||
|
* pageIndx : 현재 페이지 위치가 저장될 input 태그 id
|
||||||
|
* recordCount : 페이지당 레코드 수
|
||||||
|
* totalCount : 전체 조회 건수
|
||||||
|
* eventName : 페이징 하단의 숫자 등의 버튼이 클릭되었을때 호출될 함수 이름
|
||||||
|
*/
|
||||||
|
|
||||||
|
var gfv_pageIndex = null;
|
||||||
|
var gfv_eventName = null;
|
||||||
|
|
||||||
|
function gfn_renderPaging(params)
|
||||||
|
{
|
||||||
|
var divId = params.divId; //페이징이 그려질 div id
|
||||||
|
gfv_pageIndex = params.pageIndex; //현재 위치가 저장될 input 태그
|
||||||
|
var totalCount = params.totalCount; //전체 조회 건수
|
||||||
|
var currentIndex = $("#"+params.pageIndex).val(); //현재 위치
|
||||||
|
if($("#"+params.pageIndex).length == 0 || gfn_isNull(currentIndex) == true){
|
||||||
|
currentIndex = 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
var recordCount = params.recordCount; //페이지당 레코드 수
|
||||||
|
if(gfn_isNull(recordCount) == true){
|
||||||
|
recordCount = 20;
|
||||||
|
}
|
||||||
|
|
||||||
|
var totalIndexCount = Math.ceil(totalCount/recordCount); //전체 인덱스 수
|
||||||
|
gfn_eventName = params.eventName;
|
||||||
|
/*
|
||||||
|
* Math.floor : 소수점 버림
|
||||||
|
* Math.ceil : 소수점 올림
|
||||||
|
* Math.round : 반올림
|
||||||
|
* Math.random : 랜덤함수
|
||||||
|
* Math.sqrt : 제곱근
|
||||||
|
* Math.pow : 제곱
|
||||||
|
* Math.abs : 절대값
|
||||||
|
*/
|
||||||
|
|
||||||
|
$("#"+divId).empty();
|
||||||
|
var preStr = "";
|
||||||
|
var postStr = "";
|
||||||
|
var str = "";
|
||||||
|
|
||||||
|
var first = (parseInt((currentIndex-1)/10)*10) + 1;
|
||||||
|
var last = (parseInt(totalCount/10)==parseInt(currentIndex/10))?totalIndexCount%10:10;
|
||||||
|
var prev = (parseInt((currentIndex-1)/10)*10) - 9 > 0 ? (parseInt((currentIndex-1)/10)*10) - 9 : 1;
|
||||||
|
var next = (parseInt((currentIndex-1)/10)+1) * 10 + 1 < totalIndexCount ? (parseInt((currentIndex-1)/10)+1) * 10 + 1 : totalIndexCount;
|
||||||
|
|
||||||
|
if(totalIndexCount>10){
|
||||||
|
preStr += "<a href='#this' class='pad_5' onclick='_movePage(1)'>[<<]</a>"
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user