编写一个JAVA类和一个JSP页面,把下列信息封装到3个Student对象里
时间:2026-01-20
时间:2026-01-20
编写一个JAVA类和一个JSP页面,把下列信息封装到3个Student对象里
编写一个JAVA类和一个JSP页面,把下列信息封装到3个Student对象里,再把每个对象放到一个ArrayList对象里,再利用ArrayList对象在JSP页面的表格中显示所下表所示的信息
package st.jsp;
import java.util.ArrayList;
public class student {
public int num;
public String name;
public String sex;
public int cla;
public int sore;
public student(int num,String name,String sex,int cla,int sore){
this.num=num;
http://www.77cn.com.cn=name;
this.sex=sex;
this.cla=cla;
this.sore=sore;
}
public static void main(String []arg){
ArrayList<student> array=new ArrayList();
}
}
<%@ page language="java" import="java.util.*"
pageEncoding="utf-8" %>
<%
String path = request.getContextPath();
String basePath
import="st.jsp.student" =
编写一个JAVA类和一个JSP页面,把下列信息封装到3个Student对象里
request.getScheme()+"://"+request.getServerName()+":"+request.getServerPort()+path+"/"; %>
<!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN">
<html>
<head>
<base href="<%=basePath%>">
<title>no2</title>
<meta http-equiv="pragma" content="no-cache">
<meta http-equiv="cache-control" content="no-cache">
<meta http-equiv="expires" content="0">
<meta http-equiv="keywords" content="keyword1,keyword2,keyword3">
<meta http-equiv="description" content="This is my page">
<!--
<link rel="stylesheet" type="text/css" href="styles.css">
-->
<style type="text/css">
#a{
border-style:solid;
border-width:2px;
border-color:black;
}
.b{
border-style:solid;
border-width:2px;
border-color:black;
}
</style>
</head>
<body>
<%
String []s=new String[]{"学号","姓名","性别","班级","成绩"};
out.println("<table id='a'>");
for(int i=0;i<s.length;i++){
out.println("<th class='b'>");
out.println(s[i]);
out.println("</th>");
}
ArrayList<student> array=new ArrayList<student>();
array.add(new student(001,"李白","男",01,723));
编写一个JAVA类和一个JSP页面,把下列信息封装到3个Student对象里
array.add(new student(002,"孟浩然","男",02,689)); array.add(new student(003,"杨玉环","女",03,600)); java.util.Iterator<student> i=array.iterator(); while(i.hasNext()){
student s1=(student)i.next();
out.println("<tr>");
out.println("<td class='b'>");
out.println(s1.num);
out.println("</td>");
out.println("<td class='b'>");
out.println(http://www.77cn.com.cn);
out.println("</td>");
out.println("<td class='b'>");
out.println(s1.sex);
out.println("</td>");
out.println("<td class='b'>");
out.println(s1.cla);
out.println("</td>");
out.println("<td class='b'>");
out.println(s1.sore);
out.println("</td>");
out.println("</tr>");
}
out.println("</table>");
%>
</body>
</html>
…… 此处隐藏:249字,全部文档内容请下载后查看。喜欢就下载吧 ……
上一篇:城乡居民幸福感调查报告
下一篇:word2010基础知识试题