๐Student.java
package xyz.itwill.el;
//
public class Student {
private int num;
private String name;
//
public Student() {
// TODO Auto-generated constructor stub
}
public Student(int num, String name) {
super();
this.num = num;
this.name = name;
}
public int getNum() {
return num;
}
public void setNum(int num) {
this.num = num;
}
public String getName() {
return name;
}
public void setName(String name) {
this.name = name;
}
}
๐student_list.jsp
<%@page import="java.util.ArrayList"%>
<%@page import="xyz.itwill.el.Student"%>
<%@page import="java.util.List"%>
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<%
List<Student> studentList=new ArrayList<Student>();
studentList.add(new Student(1000, "ํ๊ธธ๋"));
studentList.add(new Student(2000, "์๊บฝ์ "));
studentList.add(new Student(3000, "์ ์ฐ์น"));
studentList.add(new Student(4000, "์ผ์ง๋งค"));
studentList.add(new Student(5000, "์ฅ๊ธธ์ฐ"));
//
request.setAttribute("studentList", studentList);
//
request.getRequestDispatcher("student_list_el.jsp").forward(request, response);
%>
๐student_list_el.jsp
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html>
<html>
<head>
<meta charset="UTF-8">
<title>MVC</title>
</head>
<body>
<h1>EL - List</h1>
<hr>
<%-- EL ํํ์์ . ์ฐ์ฐ์๋ก ์ฒจ์๋ฅผ ํํํ๋ฉด ELException ๋ฐ์ --%>
<%-- <p>ํ๋ฒ = ${studentList.0.num }, ์ด๋ฆ = ${studentList.0.name }</p> --%>
<%-- <p>ํ๋ฒ = ${studentList[0]["num"] }, ์ด๋ฆ = ${studentList[0]["name"] }</p> --%>
<p>ํ๋ฒ = ${studentList[0].num }, ์ด๋ฆ = ${studentList[0].name }</p>
<p>ํ๋ฒ = ${studentList[1].num }, ์ด๋ฆ = ${studentList[1].name }</p>
<p>ํ๋ฒ = ${studentList[2].num }, ์ด๋ฆ = ${studentList[2].name }</p>
<p>ํ๋ฒ = ${studentList[3].num }, ์ด๋ฆ = ${studentList[3].name }</p>
<p>ํ๋ฒ = ${studentList[4].num }, ์ด๋ฆ = ${studentList[4].name }</p>
</body>
</html>