- 爱易网页
-
Java教程
- 帮小弟我改个错
日期:2014-05-18 浏览次数:20609 次
帮我改个错
这个工程是测试 <jsp:useBean> <jsp:setProperty> <jsp:getProperty> 三个标签的使用的.包括三个文件,如下:
1.register.html 在地址栏输入这个文件,填写表单后单击按钮,就报错
<html>
<body>
用户信息注册: <br> <hr>
<form method=get action= "register.jsp ">
<table>
<tr> <td> 姓名: <input name=userName type= "text "> </td> </tr>
<tr> <td> 密码: <input name=password type= "password "> </td> <tr>
<tr> <td> 年龄: <input name=age type= "text "> </td> </tr>
<tr> <td> <input type=submit value= "submit "> </td> </tr>
</table>
</form>
</body>
</html>
2.register.jsp
<%@page contentType= "text/html;charset=gb2312 "%>
<jsp:useBean id= "user " scope= "page " class= "TestBean "/>
<jsp:setProperty name= "user " property= "* "/>
<html>
<body>
注册成功: <br>
<hr>
使用Bean属性方法: <br>
用户名: <%=user.getUserName()%> <br>
密码: <%=user.getPassword()%> <br>
年龄: <%=user.getAge()%> <br>
<hr>
使用getProperty: <br>
用户名: <jsp:getProperty name= "user " property= "userName "/> <br>
密码: <jsp:getProperty name= "user " property= "password "/> <br>
年龄: <jsp:getProperty name= "user " property= "age "/> <br>
</body>
</html>
3.TestBean.java
public class TestBean
{
public String userName;
public String password;
public int age;
public void setUserName(String name)
{
this.userName=name;
}
public String getUserName()
{