728x90
<< 작성된 글의 게시판 뷰 말고 새로 작성할 뷰를 작성하는 법>>
1. 공통을 사용하는 뷰 컨트롤러에 올려주고 ( write-base )
인덱스 번호가 없는 새로운 뷰 컨트롤러에 올려줌 ( questions-write-form-new )
@RequestMapping(path = "write-base")
public ModelAndView writeBase() {
return new ModelAndView("notice/write_base");
}
//새로운 글 작성 뷰 보이기
@RequestMapping(path = "questions-write-form-new")
public ModelAndView questionsWriteForm() {
return new ModelAndView("/notice/questions_write_form");
}
@RequestMapping(path = "review-write-form-new")
public ModelAndView reviewsWriteForm() {
return new ModelAndView("/notice/review_write_form");
}
2. question.jsp에
href="questions-write-form-new"로 연결하여 질문하기 눌렀을 때 뷰 나오게 하기
<div class="Header_buttonWrapper__qedG2">
<a href="questions-write-form-new" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi" style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">질문하기</span>
</a>
</div>
<< 같은 뷰일 때 하나는 수정하기,삭제하기 버튼이 필요하고 다른하나는 작성완료,뒤로가기가 필요한 경우>>
(write_base.jsp)
연결된 idx로
<c:if test="${empty commonNotice.commonContentIdx}">
idx가 없을 경우 작성완료,뒤로가기
<c:if test="${not empty commonNotice.commonContentIdx}">
idx가 있을경우 수정하기,삭제하기
또는
삼항연산자
//삼항연산자
<input class="CommunityQuestionHead__title--text CommunityQuestionHead__title--noLink" id="contentSubject" name="commonNoticeSubject" data-cy="threads-title" type="text"
placeholder="문의하실 주 제목을 적어주세요" value="${commonNotice.commonNoticeSubject != null ? commonNotice.commonNoticeSubject:''}">
<div class="CommunityEachBody__commentContainer">
<div class="CommunityCommentTemplate">
<div class="button_write_back">
<c:if test="${empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<button type="submit" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">작성완료</span>
</button>
</div>
<div class="bt_wrap2">
<a href="faq" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">뒤로가기</span>
</a>
</div>
</c:if>
<c:if test="${not empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<button type="submit" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">수정하기</span>
</button>
</div>
<div class="bt_wrap2">
<a href="faq" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">삭제하기</span>
</a>
</div>
</c:if>
</div>
</div>
</div>
<<공통 뷰 설정 시 서로다른 컬럼명일 경우>>
문의하기와 리뷰하기가 있을경우,
서로 작성되는 테이블 컬럼명이 다르므로 서로 다르게 처리해줘야한다.
그러므로 questions_write_from.jsp , review_write_form.jsp에 버튼 들만 write_base.jsp에서 이동하여 처리해준다.
주의 !! <input type="submit">은 form 태그 안에 들어가 있어야 한다.
(questions_write_from.jsp)
<div class="CommunityContentShow__q CommunityContentShow__box">
<div class="CommunityQuestionHead CommunityContentShow__q--header">
<form name="writeform" class="write-form" action="/writePro" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<jsp:include page="write_base.jsp">
<jsp:param name="pageName" value="write_base"/>
</jsp:include>
<div class="CommunityEachBody__commentContainer">
<div class="CommunityCommentTemplate">
<div class="button_write_back">
<c:if test="${empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<button type="submit" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">작성완료</span>
</button>
</div>
<div class="bt_wrap2">
<a href="questions" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">뒤로가기</span>
</a>
</div>
</c:if>
<c:if test="${not empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<input type="hidden" name="commonContentIdx" value="${commonNotice.commonContentIdx}">
<button type="submit" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">수정하기</span>
</button>
</div>
<div class="bt_wrap2">
<a href="deletePro?commonContentIdx=${commonNotice.commonContentIdx}" class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">삭제하기</span>
</a>
</div>
</c:if>
</div>
</div>
</div>
</form>
</div>
</div>
(review_write_form.jsp)
<div class="CommunityContentShow__q CommunityContentShow__box">
<div class="CommunityQuestionHead CommunityContentShow__q--header">
<form name="writeform" class="write-form" action="/reviewPro" method="post">
<input type="hidden" name="${_csrf.parameterName}" value="${_csrf.token}"/>
<jsp:include page="write_base.jsp">
<jsp:param name="pageName" value="write_base"/>
</jsp:include>
<div class="CommunityEachBody__commentContainer">
<div class="CommunityCommentTemplate">
<div class="button_write_back">
<c:if test="${empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<button type="submit"
class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">작성완료</span>
</button>
</div>
<div class="bt_wrap2">
<a href="review"
class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">뒤로가기</span>
</a>
</div>
</c:if>
<c:if test="${not empty commonNotice.commonContentIdx}">
<div class="bt_wrap1" style="float: left">
<input type="hidden" name="commonContentIdx" value="${commonNotice.commonContentIdx}">
<button type="submit"
class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">수정하기</span>
</button>
</div>
<div class="bt_wrap2">
<a href="deletePro2?commonContentIdx=${commonNotice.commonContentIdx}"
class="ButtonInteractive_container__NfRis ButtonInteractive_withIcon__ECQZi"
style="padding: 1.2rem 2.7rem 0.8rem 2.2rem;">
<span class="Header_buttonText__zPcGR">삭제하기</span>
</a>
</div>
</c:if>
</div>
</div>
</div>
</form>
</div>
</div>
728x90
'BACK' 카테고리의 다른 글
[SpringBoot JSP] 게시판-페이징 처리/방법 2 (0) | 2022.04.29 |
---|---|
[SpringBoot JSP] 게시판-페이징 처리/방법 1 (0) | 2022.04.29 |
[SpringBoot JSP] 라이브러리 없이 - header, footer 나누기 (0) | 2022.03.29 |
[SpringBoot JSP] - xml 설정(Intellij) (0) | 2022.03.29 |
[SpringBoot JSP] - DB 설정(Intellij) (0) | 2022.03.29 |