DTO
public class MemberVO { @NotEmpty @Size(min=4, max=12) private String id ; @NotEmpty @Size(min=6, max=20) private String pwd ; @NotEmpty private String pwdCheck; @NotEmpty @Size(min=2, max=12) private String name ; @NotEmpty @Email private String email ; @NotNull @NotEmpty private String zip_num; private String address ; @NotNull private String address1; private String address2; private String phone ; private String useyn ; @NotNull private String ip ; private Timestamp indate ; public boolean isPassCheck(){ if(this.pwd.equals(this.pwdCheck)){ return false; } //패스워드가 일치하지 않으면 true return true; }
AdminMemberListAction
package net.macaronics.web.admin.controller; import java.io.IOException; import java.util.List; import javax.servlet.ServletException; import javax.servlet.http.HttpServletRequest; import javax.servlet.http.HttpServletResponse; import net.macaronics.web.controll.action.Action; import net.macaronics.web.dao.MemberDAO; import net.macaronics.web.dto.MemberVO; public class AdminMemberListAction implements Action{ @Override public void execute(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException { String url="admin/member/memberList.jsp"; String key=""; if(request.getParameter("key")!=null){ key =request.getParameter("key"); } MemberDAO memberDAO =MemberDAO.getInstance(); List<MemberVO> memberList=memberDAO.listMember(key); request.setAttribute("key", key); request.setAttribute("memberList", memberList); request.getRequestDispatcher(url).forward(request, response); } }
DAO
//관리자 회원 목록 출력 public List<MemberVO> listMember(String member_name){ List<MemberVO> memberList=new ArrayList<>(); try{ sqlSession =MybatisService.getFactory().openSession(); memberList=sqlSession.selectList("member.listMember", member_name); }catch(Exception e){ e.printStackTrace(); }finally{ MybatisService.sessionClose(sqlSession); } return memberList; }
Mapper
<!-- 관리자 화면 회원 목록 출력 --> <select id="listMember" resultType="net.macaronics.web.dto.MemberVO"> <![CDATA[ select * from TBL_MEMBER where name like '%'|| #{name} || '%' order by indate desc ]]> </select>
View
<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%> <%@ taglib prefix="c" uri="http://java.sun.com/jsp/jstl/core" %> <%@ taglib prefix="fmt" uri="http://java.sun.com/jsp/jstl/fmt" %> <!DOCTYPE html> <html class="no-js"> <head> <jsp:include page="../../include/AdminHeader.jsp" /> </head> <body> <jsp:include page="../../include/AdminTopFixMenu.jsp" /> <div class="container-fluid"> <div class="row-fluid"> <div class="span3" id="sidebar"> <jsp:include page="../../include/AdminLeftMenu.jsp" /> </div> <!--/span--> <div class="span9" id="content"> <div class="row-fluid"> <div class="alert alert-success"> <button type="button" class="close" data-dismiss="alert">×</button> <h4>회원리스트</h4> </div> <div class="navbar"> <div class="navbar-inner"> <ul class="breadcrumb"> <i class="icon-chevron-left hide-sidebar"><a href='#' title="Hide Sidebar" rel='tooltip'> </a></i> <i class="icon-chevron-right show-sidebar" style="display:none;"><a href='#' title="Show Sidebar" rel='tooltip'> </a></i> <li> <form action="MacaronicsServlet" > 주문자 이름 <input type="text" name="key" value="${key =='%' ? '':key }"> <input type="hidden" value="admin_order_list" name="command" > <input type="submit" class="success" value="검색"> </form> <a href="#"></a> </li> </ul> </div> </div> </div> <div> <form method="post" action="" name="frm"> <div class="table-responsive"> <table class="table"> <tr class="success"> <th>아이디(탈퇴여부)</th> <th>이름</th> <th>이메일</th> <th>우편번호</th> <th>주소</th> <th>전화</th> <th>가입일</th> </tr> <c:if test="${empty memberList or memberList.size()==0 }" > <tr> <td colspan="6" class="text-center"> 검색된 상품이 없습니다.</td> </tr> </c:if> <c:forEach items="${memberList}" var="memverVO"> <tr> <td> ${memverVO.id} <c:choose> <c:when test="${memverVO.useyn='y'}"> (가입) </c:when> <c:otherwise> (탈퇴) </c:otherwise> </c:choose> </td> <td>${memverVO.name}</td> <td>${memverVO.email}</td> <td>${memverVO.zip_num}</td> <td>${memverVO.address}</td> <td>${memverVO.phone}</td> <td><fmt:formatDate type="date" value="${memverVO.indate}" /></td> </tr> </c:forEach> </table> </div> </form> </div> </div> </div> </div> <hr> <jsp:include page="../../include/AdminFooter.jsp" />
제작 : macaronics.net - Developer Jun Ho Choi
소스 : https://github.com/braverokmc79/jsp_sin
${request.getContextPath() } 처리를 안한 부분이 있으므로
루트 설정( http://macaronics.net/index.php/m01/jsp/view/1352) 및 server.xml 에서 DB 컨넥션 설정은 필수 설정이다.
댓글 ( 4)
댓글 남기기