@Resource(name = "loginUserBean")
private LoginUserBean loginUserBean;
<!--생략-->
@GetMapping("/read")
public String read(@RequestParam("board_info_idx") int board_info_idx,
@RequestParam("content_idx") int content_idx, Model model) {
model.addAttribute("board_info_idx", board_info_idx);
model.addAttribute("loginUserBean",loginUserBean);
//글 번호로 DB에서 게시글 내용 읽어오기
ContentBean readContentBean = boardService.getContentInfo(content_idx);
model.addAttribute("readContentBean", readContentBean);
//System.out.println("readContentBean : "+readContentBean.getContent_file());
return "board/read";
}
t1.content_writer_idx 추가
@Select("select t2.user_name as content_writer_name, " +
"DATE_FORMAT(t1.content_date, '%Y.%m.%d') as content_date," +
"t1.content_idx, t1.content_subject, t1.content_text, t1.content_file, t1.content_writer_idx " +
"from content_table t1 join user_table t2 " +
"on t1.content_writer_idx = t2.user_idx " +
"and content_idx = #{content_idx}")
ContentBean getContentInfo(int content_idx);
<c:if test="${loginUserBean.user_idx == readContentBean.content_writer_idx}">
<a href="${root }board/modify?board_info_idx=${board_info_idx}&content_idx=${content_idx}&page=${page}" class="btn btn-info">수정하기</a>
<a href="${root }board/delete?board_info_idx=${board_info_idx}&content_idx=${content_idx}&page=${page}" class="btn btn-danger">삭제하기</a>
</c:if>
글쓴사람과 로그인한사람이 동일할 때 보이는거랑 안보이는거 확인 !