@RequestMapping(
      value = "{database}/insertBoard",
      method = {RequestMethod.POST, RequestMethod.GET})
  // @ModelAttribute @Valid Board board
  public String insertBoard(
      HttpServletResponse response,
      HttpServletRequest request,
      @ModelAttribute @Valid ImageBoard imageBoard,
      @PathVariable("database") String database) {

    ImageBoardImp imageBoardImp = sqlSession.getMapper(ImageBoardImp.class);

    String fileMetaDatabase = BoardList.getFileMetaTableName(database);

    System.out.println("inserBoard3 : database : " + database);
    System.out.println("inserBoard3 : fileMetaDatabase : " + fileMetaDatabase);

    imageBoard.setDatabase(database);

    // 1. build an iterator
    // Iterator<String> itr = multiRequest.getFileNames();
    // MultipartFile mpf = null;

    Logger logger = Logger.getLogger("ImageBoard");

    int highestNum = 0;
    File fileDir = null;
    List<MultipartFile> crunchifyFiles = imageBoard.getArrMultipartFile();
    List<String> fileNames = new ArrayList<String>();

    if (null != crunchifyFiles && crunchifyFiles.size() > 0) {
      for (MultipartFile multipartFile : crunchifyFiles) {
        String fileName = multipartFile.getOriginalFilename();
        System.out.println(fileName);

        try {
          highestNum = imageBoardImp.getImageBoardHighestNum(database);
          fileDir = makeDirDatabaseNum(database, highestNum);
        } catch (Exception e) {
          fileDir = makeDirDatabaseNum(database, 1);
        }

        System.out.println("highestNum : " + highestNum);

        if (!"".equalsIgnoreCase(fileName)) {
          try {
            multipartFile.transferTo(new File(fileDir, fileName));

            imageBoard.setFileName(multipartFile.getOriginalFilename());
            imageBoard.setFileSize(multipartFile.getSize() / 1024 + " Kb");
            imageBoard.setFileType(multipartFile.getContentType());
            imageBoard.setDatabase(database);

            System.out.println(
                "fileMeta.getFileName() : " + imageBoard.getFileName() + " Inserted");

            imageBoardImp.insertImageBoard(imageBoard);

          } catch (Exception e) {
            logger.severe(e.getMessage());
            System.out.println("Error");
          }
        }
      }
    }

    return "redirect:/ImageBoard/" + database + "/" + 1;
  }
  @RequestMapping(value = "/{database}/{pageNum}", method = RequestMethod.GET)
  @Transactional
  public String imageBoard(
      @PathVariable("database") String database,
      @PathVariable("pageNum") int pageNum,
      Model model) {
    ImageBoardImp imageBoardImp = sqlSession.getMapper(ImageBoardImp.class);
    ReplyImp replyImp = sqlSession.getMapper(ReplyImp.class);
    ArrayList<ImageBoard> arrImageBoard = new ArrayList<ImageBoard>();
    ArrayList<Reply> arrReply = new ArrayList<Reply>();
    ArrayList<String> arrImageStream = new ArrayList<String>();

    if (pageNum == 0) {
      pageNum = 1;
    }

    // DB에서 List 개수 파악
    int pageSize = 10; // 가지고 올 개수
    int count = 0;
    try {
      count = imageBoardImp.getImageBoardHighestNum(database);
    } catch (Exception e) {
      count = 0;
    }
    int start = (pageNum - 1) * pageSize;
    int maxPageNum = imageBoardImp.getImageBoardCount(database);
    if ((maxPageNum % MAX_PAGEZIE) > 0) {
      maxPageNum = maxPageNum / pageSize + 1;
    } else {
      maxPageNum = maxPageNum / pageSize;
    }

    System.out.println(start);
    System.out.println(start + pageSize);

    arrImageBoard = imageBoardImp.listImageBoardPaging(database, start, pageSize);
    arrReply = replyImp.getReplyByUpDown(BoardList.getReplyTableName(database), 100, 102);
    try {
      arrImageStream = encodingImage(arrImageBoard, database);
      System.out.println("encodingImage success");
    } catch (Exception e) {
      System.out.println("encodingImage error");
      e.printStackTrace();
    }

    Iterator<ImageBoard> iterator = arrImageBoard.iterator();
    int count_1 = 0;
    while (iterator.hasNext()) {
      iterator.next().setBase64Encoded(arrImageStream.get(count_1++));
    }

    System.out.println("size : " + arrImageBoard.size());
    System.out.println(arrImageBoard.get(0).getUsername());
    System.out.println(arrImageBoard.get(0).getContent());

    model.addAttribute("maxPageNum", maxPageNum);
    model.addAttribute("pageNum", pageNum);
    model.addAttribute("database", database);
    // model.addAttribute("arrImageStream", arrImageStream);
    model.addAttribute("arrImageBoard", arrImageBoard);
    model.addAttribute("arrReply", arrReply);

    return "imageboard/imageGallery";
  }