bean的源程序:
package test;
import java.sql.*;
public class Login
{
String users="";
String usertype="";
String password="";
String success="false",
message="";
public Login()
{
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
}
public void setuserType(String No)
{
usertype=No;
}
public String getuserType()
{
return usertype;
}
public void setUsers(String name)
{
users=name;
}
public String getUsers()
{
return users;
}
public void setPassword(String number)
{
password=number;
}
public String getPassword()
{
return password;
}
public String getMessage()
{
Connection con;
Statement sql;
ResultSet rs;
try{
con=DriverManager.getConnection("jdbc:odbc:sun","sa","");
sql=con.createStatement();
String condition="select * from user WHERE users="+"'"+users+"'";
rs=sql.executeQuery(condition);
int rowcount=0;
String ps="";
String bs="";
while(rs.next())
{
rowcount++;
users=rs.getString("users");
ps=rs.getString("password");
bs=rs.getString("usertype");
}
if((rowcount==1)&&(password.equals(ps))&&(usertype.equals(bs)))
{
message="ok";
success="ok";
}
else
{
message="输入的用户名或密码不正确";
success="false";
}
con.close();
return message;
}
catch(SQLException e)
{
message="输入的用户名或密码不正确";
success="false";
return message;
}
}
}<%@ page import="test.Login"%>
<jsp:useBean id="g" class="test.Login" scope="page">
</jsp:useBean>
<jsp:setProperty name="g" property="passwrd" value="t" />
<jsp:getProperty name="g" property="password" />
能测试通过,而
<%@ page import="test.Login"%>
<jsp:useBean id="g" class="test.Login" scope="page">
</jsp:useBean>
<jsp:setProperty name="g" property="usertype" value="t" />
<jsp:getProperty name="g" property="usertype" />
却报错
Cannot find any information on property 'usertype' in a bean of type 'test.Login'
package test;
import java.sql.*;
public class Login
{
String users="";
String usertype="";
String password="";
String success="false",
message="";
public Login()
{
try{Class.forName("sun.jdbc.odbc.JdbcOdbcDriver");
}
catch(ClassNotFoundException e){}
}
public void setuserType(String No)
{
usertype=No;
}
public String getuserType()
{
return usertype;
}
public void setUsers(String name)
{
users=name;
}
public String getUsers()
{
return users;
}
public void setPassword(String number)
{
password=number;
}
public String getPassword()
{
return password;
}
public String getMessage()
{
Connection con;
Statement sql;
ResultSet rs;
try{
con=DriverManager.getConnection("jdbc:odbc:sun","sa","");
sql=con.createStatement();
String condition="select * from user WHERE users="+"'"+users+"'";
rs=sql.executeQuery(condition);
int rowcount=0;
String ps="";
String bs="";
while(rs.next())
{
rowcount++;
users=rs.getString("users");
ps=rs.getString("password");
bs=rs.getString("usertype");
}
if((rowcount==1)&&(password.equals(ps))&&(usertype.equals(bs)))
{
message="ok";
success="ok";
}
else
{
message="输入的用户名或密码不正确";
success="false";
}
con.close();
return message;
}
catch(SQLException e)
{
message="输入的用户名或密码不正确";
success="false";
return message;
}
}
}<%@ page import="test.Login"%>
<jsp:useBean id="g" class="test.Login" scope="page">
</jsp:useBean>
<jsp:setProperty name="g" property="passwrd" value="t" />
<jsp:getProperty name="g" property="password" />
能测试通过,而
<%@ page import="test.Login"%>
<jsp:useBean id="g" class="test.Login" scope="page">
</jsp:useBean>
<jsp:setProperty name="g" property="usertype" value="t" />
<jsp:getProperty name="g" property="usertype" />
却报错
Cannot find any information on property 'usertype' in a bean of type 'test.Login'
public void setUserType(String No)
{
usertype=No;
}
public String getUserType()
{
return usertype;
}