SearchBoardController.java > SPRING1

본문 바로가기
사이트 내 전체검색

SPRING1

SearchBoardController.java

페이지 정보

profile_image
작성자 관리자
댓글 0건 조회 108회 작성일 24-07-31 18:09

본문

package com.pkt.controller;


import org.springframework.stereotype.Controller;

import org.springframework.ui.Model;

import org.springframework.web.bind.annotation.GetMapping;

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

import org.springframework.web.bind.annotation.PostMapping;

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

import org.springframework.web.bind.annotation.RequestMethod;

import org.springframework.web.bind.annotation.RequestParam;

import org.springframework.web.servlet.mvc.support.RedirectAttributes;


import com.pkt.model.BoardVO;

import com.pkt.model.Criteria;

import com.pkt.model.PageMaker;

import com.pkt.service.BoardService;


import lombok.AllArgsConstructor;

import lombok.extern.log4j.Log4j;


@Controller

@Log4j

@RequestMapping("/sboard/")

@AllArgsConstructor

public class SearchBoardController {


private BoardService service;


@GetMapping("list")

public void list(@ModelAttribute("cri") Criteria cri, Model model) {

log.info(cri.toString());


model.addAttribute("list", service.listSearchCriteria(cri));


PageMaker pageMaker = new PageMaker();


pageMaker.setCri(cri);

pageMaker.setTotalCount(service.listSearchCount(cri));


model.addAttribute("pageMaker", pageMaker);

}


@GetMapping("read")

public void read(@RequestParam("bno") int bno, @ModelAttribute("cri") Criteria cri, Model model) {

PageMaker pageMaker = new PageMaker();

pageMaker.setCri(cri);

model.addAttribute("pageMaker", pageMaker);

model.addAttribute(service.readOne(bno));

}


@GetMapping("modify")

public void modifyGET(int bno, @ModelAttribute("cri") Criteria cri, Model model) {

model.addAttribute(service.readOne(bno));

}


@PostMapping("modify")

public String modifyPOST(BoardVO board, Criteria cri, RedirectAttributes rttr) {

log.info(cri.toString());


service.modify(board);


rttr.addAttribute("page", cri.getPage());

rttr.addAttribute("perPageNum", cri.getPerPageNum());

rttr.addAttribute("searchType", cri.getSearchType());

rttr.addAttribute("keyword", cri.getKeyword());

rttr.addFlashAttribute("msg", "modify");


log.info(rttr.toString());


return "redirect:/sboard/list";

}


@GetMapping("remove")

public String remove(@RequestParam("bno") int bno, Criteria cri, RedirectAttributes rttr) {

service.remove(bno);


rttr.addAttribute("page", cri.getPage());

rttr.addAttribute("perPageNum", cri.getPerPageNum());

rttr.addAttribute("searchType", cri.getSearchType());

rttr.addAttribute("keyword", cri.getKeyword());


rttr.addFlashAttribute("msg", "delete");


return "redirect:/sboard/list";

}


@GetMapping("register")

public void registGET() {

log.info("regist get ...........");

}


@PostMapping("register")

public String registPOST(BoardVO board, RedirectAttributes rttr) throws Exception {

log.info("regist post ...........");

log.info(board.toString());


service.regist(board);


rttr.addFlashAttribute("msg", "register");


return "redirect:/sboard/list";

}


// reply 추가

@GetMapping("reply")

public void ajaxTest() {

log.info("reply get ..........."); 

}


}

댓글목록

등록된 댓글이 없습니다.

회원로그인

회원가입

사이트 정보

공지사항
자유게시판
질문답변
1:1문의

 

별명 : 터푸가위
주소 : 부산시 동래구 명장로20번길 90
대표 : 박규태
메일 : dancepkt@******.com

접속자집계

오늘
19
어제
371
최대
10,760
전체
268,392
Copyright © dancePKT . All rights reserved.