#jsp mvc03

제로·2023년 1월 4일
0

JSP

목록 보기
26/30

2단계 예재(DB불러오기)

## A05.MVC.java

@WebServlet(name = "mvc05.do", urlPatterns = { "/mvc05.do" })
public class A05_MVC extends HttpServlet {
	private static final long serialVersionUID = 1L;

	/**
	 * @see HttpServlet#service(HttpServletRequest request, HttpServletResponse response)
	 */
	protected void service(HttpServletRequest request, HttpServletResponse response) throws ServletException, IOException {
		// TODO Auto-generated method stub
		
		//모델 데이터 empList
		A02_EmpDao dao = new A02_EmpDao();
		request.setAttribute("empList",dao.getEmpSch(new Emp("","",0,9999)) );
		// view 호출
		String page = "WEB-INF\\a01_mvc\\a05_view.jsp";
		request.getRequestDispatcher(page).forward(request, response);
	}

}

## a05_view.jsp
	<h2>사원 정보 리스트</h2>
	<table>
		<tr><th>사원번호</th><th>사원명</th><th>직책</th></tr>
		<c:forEach var="emp" items="${empList }">
		<tr><td>${emp.empno }</td><td>${emp.ename }</td><td>${emp.job }</td></tr>
		</c:forEach>
	</table>

profile
아자아자 화이팅

0개의 댓글