主题:在jsp中导入自定义类为什么出错了
我想在jsp页面中导入一个学生对象,为何出错了,是不是我导包错误啊,
学生对象的类在下面
有哪位高手能指点一下吗?
多谢了!!!
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.util.*"%>
<%--这里是我导入学生对象的包--%>
<%@page import="studentinfo.Student"%>
<%
Student stu1 = new Student();
stu1.stuID = "001";
stu1.stuName = "李白";
stu1.stuSex = "男";
stu1.stuClass = "01";
stu1.stuGrade = 723.0;
Student stu2 = new Student();
stu2.stuID = "002";
stu2.stuName = "孟浩然";
stu2.stuSex = "男";
stu2.stuClass = "02";
stu2.stuGrade = 689.0;
Student stu3 = new Student();
stu3.stuID = "003";
stu3.stuName = "杨玉环";
stu3.stuSex = "女";
stu3.stuClass = "03";
stu3.stuGrade = 600.0;
List stus = new ArrayList();
stus.add(stu1);
stus.add(stu2);
stus.add(stu3);
%>
<html>
<head>
<title>显示学生信息</title>
</head>
<body bgcolor="#ffffff">
<table align="center" width="75%" border="1">
<tr>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>班级</td>
<td>成绩</td>
</tr>
<%
for (int i = 0; i < stus.size(); i++) {
Student stu = (Student) stus.get(i);
%>
<tr>
<td><%=stu.stuID%></td>
<td><%=stu.stuName%></td>
<td><%=stu.stuSex%></td>
<td><%=stu.stuClass%></td>
<td><%=stu.stuGrade%></td>
</tr>
<%}%>
</table>
</body>
</html>
//这个类是一个学生对象,在包studentinfo下
package studentinfo;
public class Student {
public String stuID;
public String stuName;
public String stuSex;
public String stuClass;
public double stuGrade;
public Student() {
}
}
学生对象的类在下面
有哪位高手能指点一下吗?
多谢了!!!
<%@page contentType="text/html; charset=GBK"%>
<%@page import="java.util.*"%>
<%--这里是我导入学生对象的包--%>
<%@page import="studentinfo.Student"%>
<%
Student stu1 = new Student();
stu1.stuID = "001";
stu1.stuName = "李白";
stu1.stuSex = "男";
stu1.stuClass = "01";
stu1.stuGrade = 723.0;
Student stu2 = new Student();
stu2.stuID = "002";
stu2.stuName = "孟浩然";
stu2.stuSex = "男";
stu2.stuClass = "02";
stu2.stuGrade = 689.0;
Student stu3 = new Student();
stu3.stuID = "003";
stu3.stuName = "杨玉环";
stu3.stuSex = "女";
stu3.stuClass = "03";
stu3.stuGrade = 600.0;
List stus = new ArrayList();
stus.add(stu1);
stus.add(stu2);
stus.add(stu3);
%>
<html>
<head>
<title>显示学生信息</title>
</head>
<body bgcolor="#ffffff">
<table align="center" width="75%" border="1">
<tr>
<td>学号</td>
<td>姓名</td>
<td>性别</td>
<td>班级</td>
<td>成绩</td>
</tr>
<%
for (int i = 0; i < stus.size(); i++) {
Student stu = (Student) stus.get(i);
%>
<tr>
<td><%=stu.stuID%></td>
<td><%=stu.stuName%></td>
<td><%=stu.stuSex%></td>
<td><%=stu.stuClass%></td>
<td><%=stu.stuGrade%></td>
</tr>
<%}%>
</table>
</body>
</html>
//这个类是一个学生对象,在包studentinfo下
package studentinfo;
public class Student {
public String stuID;
public String stuName;
public String stuSex;
public String stuClass;
public double stuGrade;
public Student() {
}
}