jsp
<form name="registerClubFrm" enctype="multipart/form-data">
<div id="simple-list-item-0" class="container" style="border:solid 0px black; margin-top: 12%;">
<div class="row">
<div class="col-8">
<div data-bs-spy="scroll" data-bs-target="#simple-list-example" data-bs-offset="0" data-bs-smooth-scroll="true" class="scrollspy-example" tabindex="0">
<h3 id="simple-list-item-1" style="font-weight: bolder;">기본정보</h3>
<hr>
<div id="profile">
<%-- ==== 이미지파일 미리보여주기 ==== --%>
<div id="pview" style="border:solid 1px gray; z-index:2; position: absolute; width: 30%; height: 180px;" >
<div style="margin-top: 35%; margin-left: 31%; ">대표 이미지</div>
</div>
<div id="preview" style="border:solid 0px red; z-index: 1; position: relative;" >
<img id="previewImg" width="300" /> <!-- 밑에서 첨부파일 추가바면 자동으로 보이게끔 -->
</div>
<!-- 종목 -->
<div id="infoo">
<select name="fk_sportseq" style="width:80%;" id="category" class="form-select-lg mb-3" aria-label="Large select example">
<option value="종목">종목</option>
<option value="1">축구</option>
<option value="2">야구</option>
<option value="3">배구</option>
<option value="4">농구</option>
<option value="5">테니스</option>
<option value="6">볼링</option>
<option value="7">족구</option>
<option value="8">배드민턴</option>
</select>
<div id="name" style="font-size: 25px; font-weight: bold; ">${sessionScope.loginuser.name}</div> <!-- 자동 -->
<div style="color: lightgray;">🕻 연락처</div><span>${sessionScope.loginuser.mobile}</span> <!-- 자동 -->
<div style="color: lightgray;">✉️ 이메일</div><span>${sessionScope.loginuser.email}</span> <!-- 자동 -->
</div>
</div>
<br><br><br><br>
<!-- 동호회명 -->
<h3 id="simple-list-item-2" style="font-weight: bolder;">동호회명<span style="color: red;">*</span></h3>
<hr>
<input name="clubname" id="form-control-lg" type="text" placeholder="동호회 이름을 입력하세요. " aria-label="">
<br><br><br><br>
<!-- 지역 -->
<h3 id="simple-list-item-3" style="font-weight: bolder;">지역<span style="color: red;">*</span></h3>
<hr>
<span class="location" style="font-weight: bolder;">활동 지역</span>
<select name="city" id="city" class="form-select form-select-lg mb-3" aria-label="Large select example">
<option value="0">선택하세요</option>
<c:forEach var="city" items="${requestScope.cityList}">
<option value="${city.cityname}">${city.cityname}</option>
</c:forEach>
</select>
<select name="local" id="local" class="form-select form-select-lg mb-3" aria-label="Large select example"></select>
<span style="font-weight: bolder;"> 활동 구장</span>
<input name="clubgym" id="form-control-lg" type="text" placeholder="oo체육관" aria-label="">
<br><br><br><br>
<h3 id="simple-list-item-4" style="font-weight: bolder;">운영 시간<span style="color: red;">*</span></h3>
<hr>
<span style="font-weight: bolder;">주요 활동 시간대</span>
<input name="clubtime" id="form-control-lg" type="text" placeholder="00:00 ~ 00:00" aria-label="">
<br><br><br><br>
<h3 id="simple-list-item-5" style="font-weight: bolder;">정원<span style="color: red;">*</span></h3>
<hr>
<label for="customRange3" class="form-label">최대 정원은 30명 까지입니다.</label>
<br>
<div style="display: flex;">
<input name="membercount" class="form-control form-control-lg" type="text" placeholder="" aria-label="" style="width: 20%;"><div style="font-weight: bold; padding-top: 20px; margin-left: 10px;">명</div>
</div>
<!--
1
<input name="membercount" style="width:80%;" value="1" type="range" class="form-range slider" min="0" max="30" step="1" id="customRange3">
${requestScope.membercnt}
<span class="value" id="rangeValue"></span>
-->
<br><br><br><br>
<h3 id="simple-list-item-6" style="font-weight: bolder;">회비<span style="color: red;">*</span></h3>
<hr>
<div style="display: flex;">
<input name="clubpay" class="form-control form-control-lg" type="text" placeholder="" aria-label="" style="width: 30%;"><div style="font-weight: bold; padding-top: 20px; margin-left: 10px;">원</div>
</div>
<br><br><br><br>
<h3 id="simple-list-item-7" style="font-weight: bolder;">동호회 대표 이미지<span style="color: red;">*</span></h3>
<hr>
<input class="img_file" id="clubimg" type="file" name="attach" />
<br><br><br><br>
</div>
</div>
<div class="col-4">
<div id="simple-list-example" class="d-flex flex-column gap-2 simple-list-example-scrollspy">
<div style="margin-bottom: 1rem;">필수 입력사항</div>
<br>
<a class="p-1 rounded" href="#simple-list-item-0"><em>✔️</em>기본정보</a>
<a class="p-1 rounded" href="#simple-list-item-1"><em>✔️</em>동호회명</a>
<a class="p-1 rounded" href="#simple-list-item-2"><em>✔️</em>지역</a>
<a class="p-1 rounded" href="#simple-list-item-3"><em>✔️</em>운영시간</a>
<a class="p-1 rounded" href="#simple-list-item-4"><em>✔️</em>정원</a>
<a class="p-1 rounded" href="#simple-list-item-5"><em>✔️</em>회비</a>
<a class="p-1 rounded" href="#simple-list-item-6"><em>✔️</em>대표 이미지</a>
</div>
</div>
</div>
<input type="hidden" name="fk_userid" value="${sessionScope.loginuser.userid}" />
<input type="hidden" name="clubtel" value="${sessionScope.loginuser.mobile}" />
<div style="margin: 20px;">
<button type="button" class="btn btn-secondary btn-sm mr-3" id="btnRegister">등록하기</button>
<button type="button" class="btn btn-secondary btn-sm" onclick="javascript:history.back()">취소</button>
</div>
</div>
</form>
js
등록 버튼을 클릭하면 data에 where 절에 필요한 userid와 category 를 넣어서 보내준다.
원래는 cotroller 에서 검사 해주는 건 줄 알았다. 그게아니고
ajax로 보내는 이유는 다시 돌아와서 값을 보내기 전에 막아야 하니까.
controller
컨트롤러에서 ajax로 보낸 userid, category 를 받아오고, 받아온 값으로 db에서 조회(select) 하기 위해
map에 담아서 service로 보내준다.
service
받아온 맵을 다시 dao로 보내준다.
dao
받아온 값들을 dao에서 또 다시 맵퍼로 넘겨준다.
mapper
해당하는 아이디가 가입한 동호회의 종목시쿼스 개수를 알아와서
js에서 막아줄 것이다.
( sportseq실제컬럼, category는 ajax 보낼때 지어준 이름인데 값은 sportseq)
js
등록버튼 -> 개발자도구 콘솔창
{"checkseq":"1"} 가입한 이력이 있는 종목이라서 1이 뜬다.
결과
'수업 > 프로젝트' 카테고리의 다른 글
파이널 프로젝트 - 동호회 등록완료 요청 (0) | 2024.07.08 |
---|---|
파이널 프로젝트 - 동호회등록 폼 ajax로 보내기 (1) | 2024.07.07 |