📄 loginbean.java~4~
字号:
package weblogiclogin;
import javax.naming.Context;
import javax.naming.InitialContext;
import javax.rmi.PortableRemoteObject;
import java.util.*;
import weblogic.*;
public class LoginBean
{ String logname;
String password;
String message=""; //用来返回登录是否成功的消息。
UsersRemote calc;
public LoginBean()
{
Context ic = null;
try{
Hashtable ht =new Hashtable();
ht.put(Context.INITIAL_CONTEXT_FACTORY,"weblogic.jndi.WLInitialContextFactory");
ht.put(Context.PROVIDER_URL,"t3://localhost:7001");
ic=new InitialContext(ht);
Object obj = ic.lookup("UsersLocal");
UsersRemoteHome home = (UsersRemoteHome)PortableRemoteObject.narrow(obj,UsersRemoteHome.class);
calc = home.findByPrimaryKey(logname);
}
catch(Exception ex)
{
System.err.println("Caught an unexpected exception!");
ex.printStackTrace();
}
}
//设置属性值、获取属性值的方法:
public void setLogname(String name)
{ logname=name;
}
public String getLogname()
{return logname;
}
public void setPassword(String pw)
{ password=pw;
}
public String getPassword()
{return password;
}
public String getMessage()
{ String pass="";
try{
pass = calc.getPassword();
}
catch(Exception e)
{}
if(pass.equals(password))
{
try{
message = calc.getPassword();
}
catch(Exception e){}
}
else
message="输入的用户名或密码不正确";
return message;
}
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -