最简单的JSP+javaBena,大家看看到底哪里出了错?
//Bean程序 Student.java
package ch01;
class Student
{
private String name;
private String id;
private int age;
private boolean query;
public Student(){
name= "张三 ";
id= "200101 ";
age=25;
query=false;
}
public void setName(String name){ this.name=name; }
public void setId(String id) { this.id=id; }
public void setAge(int age) { this.age=age; }
public void setQuery(boolean query){ this.query=query; }
public String getName() { return name; }
public String getId() { return id; }
public int getAge() { return age; }
public boolean getQuery() { return query; }
}
//demo03.jsp程序
<%@ page contentType= "text/html; charset=gb2312 "%>
<%@ page import= "ch01.Student "%>
</jsp:useBean id= "student " class= "ch01.Student " scope= "session "/>
<jsp:setProperty name= "student " property= "* "/>
<jsp:setProperty name= "student " property= "age " value= "30 "/>
<html>
<head>
<title> 使用存取JavaBean的三个action元素 </title>
</head>
<body>
<%if(student.getQuery()){%>
<h2> 查询结果: </h2> <br>
姓名: <jsp:getProperty name= "student " property= "name "/> <br>
学号: <jsp:getProperty name= "student " property= "id "/> <br>
年龄: <jsp:getProperty name= "student " property= "age "/> <br>
<%}%>
<hr>
<h2>
学生
</h2>
<form name= "javabean " action= "demo03.jsp " method=get ">
<input type= "hidden " name= "query " value= "true ">
<p> 姓名: <input type = "text " name= "name ">
<p> 学号: <input type = "text " name= "id ">
<p>
<input type= "submit " value= "提交 ">
<input type= "reset " value= "重置 ">
</p>
</form>
</body>
</html>
------解决方案-------------------- </jsp:useBean id= "student " class= "ch01.Student " scope= "session "/>
去掉前面的 "/ "试下
------解决方案-------------------- <jsp:useBean id= "student " class= "ch01.Student " scope= "session ">
<jsp:setProperty name= "student " property= "* "/>
<jsp:setProper