action中
如果没有get和set方法
用request设置属性,再在JSP中拿出来
如果有get和set 方法,在JSP中直接可以用
String hql="from Student";//Student是和某张表对应的JavaBean
list=session.createQuery(hql).list();
在JSP中
<%@ page language="java" contentType="text/html; charset=utf-8"
pageEncoding="utf-8"%>
<%@ page import="java.util.*" %>
<%@ page import="com.ttt.hibernate.Student" %>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>学生列表</title>
</head>
<body>
<%
System.out.println("aaa");
List<Student> lsit = (List<Student>)request.getAttribute("list");%>
<table border=1>
<th>学生编号</th>
<th>密码</th>
<th>名字</th>
<th>性别</th>
<th>班级</th>
<%for(int i=0;i<lsit.size();i++){
Student student=(Student) lsit.get(i);%>
<tr>
<td><%=student.getStudentNo() %></td>
<td><%=student.getPassword() %></td>
<td><%=student.getName() %></td>
<td><%=student.getSex() %></td>
<td><%=student.getBanji() %></td>
</tr>
<%}%>
</table>
</body>
</html>