高手帮我看看 我这个JAVABEAN 返回值是不是有问题?前台无法正确判断result的值
我写的一个用户登陆判断的JAVABEAN
package bean.js;
import java.sql.*;
public class UserRegist
{
String userid;
String userpassword;
public String getuserid()
{
return userid;
}
public void setuserid(String c)
{
userid=c;
}
public String getuserpassword()
{
return userpassword;
}
public void setuerpassword(String d)
{
userpassword=d;
}
//连接数据库
public UserRegist()
{
try{
Class.forName( "sun.jdbc.odbc.JdbcOdbcDriver ");
}
catch(
ClassNotFoundException e) {}
}
public Boolean getResult()
{
int a=0;
int b=0;
Boolean result=true;
Connection con=null;
Statement sql=null;
ResultSet rs=null;
try{
con=DriverManager.getConnection( "jdbc:odbc:sun ", "sa ", " ");
sql=con.createStatement();
String cd= "SELECT * FROM UserInfo ";
rs=sql.executeQuery(cd);
while(rs.next())
{
String str1=rs.getString(1).trim();
String str2=rs.getString(2).trim();
if(str1.equals(userid)){ a=1;
if(str2.equals(userpassword)) b=1;
}
}
if(a==1&&b==1)
{result=true;}
else{
result=false;
}
}
catch(
SQLException e1) {}
return result;
}
}
前台无法正确分辨 result的值
------解决方案--------------------package bean.js;
import java.sql.*;
public class UserRegist
{
String userid;
String userpassword;
public String getuserid()
{
return userid;
}
public void setuserid(String c)
{
userid=c;
}
public String getuserpassword()
{
return userpassword;
}
public void setuerpassword(String d)
{
userpassword=d;
}
//连接数据库
public UserRegist()
{
try{
Cla