상단메뉴의 각 게시판 클릭시 인덱스번호로 요청하기
@GetMapping("/main")
public String main(@RequestParam("board_info_idx") int board_info_idx, Model model) {
model.addAttribute("board_info_idx", board_info_idx);
return "board/main";
}
<div class="text-right">
<a href="${root }board/write?board_info_idx=${board_info_idx }" class="btn btn-primary">글쓰기</a>
</div>
글쓰기 버튼을 눌렀을시 맴핑주소가 id로 보여진다.
<%@ taglib prefix="form" uri="http://www.springframework.org/tags/form" %>
<form:form action="${root }board/write_pro" method="post" modelAttribute="writeContentBean">
<div class="form-group">
<form:label path="content_subject">제목</form:label>
<form:input path="content_subject" class="form-control" />
<form:errors path="content_subject" style="color:red" />
</div>
<div class="form-group">
<form:label path="content_text">내용</form:label>
<form:textarea path="content_text" class="form-control" rows="10" style="resize: none"/>
<form:errors path="content_text" style="color:red" />
</div>
<div class="form-group">
<form:label path="content_file">첨부 이미지</form:label>
<form:input type="file" path="content_file" class="form-control" accept="image/*" />
</div>
<div class="form-group">
<div class="text-right">
<form:button type="submit" class="btn btn-primary">작성하기</form:button>
</div>
</div>
</form:form>
@GetMapping("/write")
public String write(@ModelAttribute("writeContentBean") ContentBean writeContentBean) {
return "board/write";
}