#jsp mvc02

제로·2023년 1월 4일
0

JSP

목록 보기
25/30

2단계 예재

## A03_MVC.java

@WebServlet(name = "mvc02_1.do", urlPatterns = { "/mvc02_1.do" })
public class A03_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
		//1. 요청처리
		//2. 모델처리 (모델 데이터 만들기)
		request.setAttribute("model01", "홍길동");
		request.setAttribute("model02", 25);
		request.setAttribute("dept", new Dept(10,"인사","서울강북"));
		
		//3. View단 호출
		String page="WEB-INF\\a01_mvc\\a03_view.jsp"; 
		RequestDispatcher rd = request.getRequestDispatcher(page);
		rd.forward(request, response);
	}

}

##a03_view.jsp

<h2>MVC2 모델데이터 처리</h2>
<h3>이름: ${model01 }</h3>
<h3>나이: ${model02 }</h3>
<h3>부서: ${dept.deptno },${dept.dname},${dept.loc }</h3>

profile
아자아자 화이팅

0개의 댓글