kenzi

mvc2로 관리자 기능 본문

프로젝트

mvc2로 관리자 기능

kenzi 2022. 4. 18. 17:57

흐름 

일반 유저 

모든 게시판 글쓰기 활성화 but boardid = 4는 비활성화 

관리자 

모든 게시판 글쓰기 비활성화 but boardid = 4만 활성화 

<c:if test="${memberNickname != '관리자' }">
<%--일반유저이고 --%>
		<c:if test="${boardid != 4 }">
		<%--공지를 제외한 모든 게시판은 --%>
				<div class="mb-2" style="float: right">
                        	<%--글쓰기 버튼을 띄운다 --%>
							<button type="button" class="btn btn-dark"
								onclick="location.href='<%=request.getContextPath()%>/community/comWriteForm'">글쓰기
							</button>
				</div>
		</c:if>
</c:if>
				
<c:if test = "${memberNickname == '관리자' }">
<%--관리자이고 --%>
		<c:if test = "${boardid == 4 }" >
		<%--공지게시판만 --%>
				<div class="mb-2" style="float: right">
                		<%--글쓰기 버튼을 띄운다 --%>
							<button type="button" class="btn btn-dark"
								onclick="location.href='<%=request.getContextPath()%>/community/comWriteForm'">글쓰기
							</button>
				</div>
		</c:if>
</c:if>

처음에는 이렇게 if문만 이중으로 썼는데 

 

뭔가 choose when otherwise를 쓸수 있지 않을까 싶어서 

<c:choose>
	<c:when test="${memberNickname != '관리자' }">
	<%--만약 1)일반유저이고 --%>
			<c:if test="${boardid != 4 }">
			<%--게시판이 4(공지)가 아니면 --%>				
					<div class="mb-2" style="float: right">
                			<%--글쓰기 버튼을 띄운다 --%>
							<button type="button" class="btn btn-dark"
									onclick="location.href='<%=request.getContextPath()%>/community/comWriteForm'">글쓰기
							</button>
					</div>
			</c:if>
	</c:when>
				
	<c:otherwise>
	<%--아니면 유저가 관리자이고 --%>
			<c:if test = "${boardid == 4 }" >
			<%--공지게시판이면 --%>		
					<div class="mb-2" style="float: right">
                			<%--글쓰기 버튼을 띄운다 --%>
							<button type="button" class="btn btn-dark"
									onclick="location.href='<%=request.getContextPath()%>/community/comWriteForm'">글쓰기
							</button>
					</div>
			</c:if>
	</c:otherwise>
</c:choose>

 

이렇게 바꿔봤는데 별로 차이가 없는거 같기도 하고 ... 

좀 더 단순해질까 싶어서 바꿔봤는데 별로 안 단순하다 ㅋㅋㅋㅋㅋㅋ

 

 

 

저녁에는 일반 유저가 문의사항 글 올리면 관리자 알림 가게 해야겠다 

'프로젝트' 카테고리의 다른 글

오라클 검색 쿼리  (0) 2022.04.27
오늘은 관리자 기능 완성할 것!  (0) 2022.04.19
오늘 구현(신고 완료~~)  (0) 2022.04.13
신고 기능과 에러(jstl 태그,jsp주석처리)  (0) 2022.04.13
프로젝트 수정 flow  (0) 2022.04.11
Comments