신고 게시판 삭제

류한선·2024년 3월 18일

2차 프로젝트

목록 보기
19/32

현재 삭제기능을 구현하였는데 삭제를 클릭하니까 신고글 전체가 삭제되고
새로고침하니까 (Entity must not be null) 가 떳다.

@PreAuthorize("isAuthenticated()")
    @GetMapping("/report/delete/{id}")
    public String reportDelete(@PathVariable("id") Integer id,Principal principal){

        Report report = this.reportService.getReportList(id);

        Member member =  this.memberService.findByUsername(principal.getName());
        if (member == null) {
            // 작성자를 찾을 수 없는 경우에 대한 처리
            return "redirect:/book/list"; // 예시로 홈 페이지로 리다이렉트
        }
        this.reportService.delete(report);

        return "redirect: /report_list"; <----여기 리다이렉트가 문제이다.
    }

return "redirect: /report/list"; 이렇게 해주니까 해결되었다.

0개의 댓글