Web/Servlet-JSP
Servlet-JSP MVC07 - 리스트에 이미지 띄우고, 상세페이지에서 파일보기
now0204
2023. 7. 22. 23:35
1. 회원리스트에 이미지 띄우기
- MemberList.jsp에 회원정보 출력되는 테이블 휴대폰 번호 밑에 아래와 같이 이미지를 띄우도록 추가하면 된다.
<td>
<c:if test="${vo.filename !=null && vo.filename !='' }">
<img src="<c:out value='file_REPO/${vo.filename}'/>" width ="60px" height="60px" >
</c:if>
*이미지 파일의 경로는 루트디렉토리에 file_REPO폴더안에 있다. <c:out> 태그를 이용해 루트 디렉토리는
자동으로 추가하고, 폴더명이랑 파일명만 적어두자
2. 회원상세페이지에 파일 띄우기
<div class="form-group">
<label class="control-label col-sm-2">첨부파일</label>
<div class="col-sm-10">
<input type="file" id ="file" name="file"> <!-- 파일첨부 수정하려고 -->
<c:if test="${vo.filename != null && vo.filename != ''}">
<c:out value="${vo.filename}"/>
</c:if>
<c:if test="${sessionScope.userId != null && sessionScope.userId == vo.id && vo.filename != null && vo.filename != ''}">
<span class="glyphicon glyphicon-remove"></span>
</c:if>
</div>
- 아래와 같이 div를 하나 추가해주자.
- 삭제버튼을 추가했는데 로그인 + 첨부파일이 있을 경우에만 x버튼이 뜨도록 만들었다.
참고자료: 나프2탄(박매일) - 인프런
https://www.inflearn.com/course/%EB%82%98%ED%94%84-mvc-2/dashboard
[NarP Series] MVC 프레임워크는 내 손에 [나프2탄] - 인프런 | 강의
본 과정은 WEB MVC 프레임워크가 무엇이고 WEB MVC 프레임워크가 어떻게 변형이 되면서 Spring WEB MVC 프레임워크로 넘어가는지 TPC(생각하고-표현하고-코딩하고) 기법을 통해 단계적으로 학습하고 이
www.inflearn.com