首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > JAVA > Java Web开发 >

最简单的JSP+javaBena,大家看看到底哪里出了错?该如何解决

2012-01-02 
最简单的JSP+javaBena,大家看看到底哪里出了错?//Bean程序Student.javapackagech01classStudent{privateS

最简单的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:setProperty name= "student " property= "age " value= "30 "/>


</jsp:useBean>
[解决办法]
<%@ page contentType= "text/html; charset=gb2312 "%>
<%@ page import= "csdn01.Bean1 "%>
<jsp:useBean id= "student " class= "csdn01.Bean1 " 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= "jsp1.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>


都是小问题,另外问一句,您是用记事本编的程序么?这错也不提示么?

热点排行