运行环境tomcat5.5.12,现有一页面和一javaBean
<%@page contentType="text/html;charset=gb2312" %>
<jsp:useBean id="user" class="com.yj.User" scope="page"> //问题出在这里,我输入用户名点登陆提交的还是这个页面
<jsp:setProperty name="user" property="*"/> //如果scope设为page,则能显示出loginname,而我设为
</jsp:useBean> //session,为什么获取不到值?session的范围大于page啊
<html>
<body>
<h1>用户登陆</h1>
<form action="login1.jsp" method="post">
<table>
<tr>
<td>用户名</td>
<td><input type="text" name="loginname" value="${user.loginname}"></td>
</tr>
<tr>
<td>密码</td>
<td><input type="password" name="password"></td>
</tr>
<tr>
<td>真实姓名</td>
<td><input type="text" name="username"></td>
</tr>
<tr>
<td>年龄</td>
<td><input type="text" name="age"></td>
</tr>
<tr>
<td>地址</td>
<td><input type="text" name="address"></td>
</tr>
<tr>
<td align="right"><input type="submit" value="登录"></td>
<td><input type="button" value="注册"></td>
</tr>
</table>
</form>
</body>
</html>
javaBean
package com.yj;
public class User {
private String loginname = "";
private String password = "";
private String username = "";
private int age = 0;
private String address = "";
public void setLoginname(String loginname) {
this.loginname = loginname;
}
public String getLoginname() {
return loginname;
}
public void setPassword(String password) {
this.password = password;
}
public String getPassword() {
return password;
}
public void setUsername(String username) {
this.username = username;
}
public String getUsername() {
return username;
}
public void setAge(int age) {
this.age = age;
}
public int getAge() {
return age;
}
public void setAddress(String address) {
this.address = address;
}
public String getAddress() {
return address;
}
}