if (username.equals("admin")) { if (password.equals("password")) { return "xxxxxx"; } else { // 抛出LoginFailedException: throw new LoginFailedException("Bad username or password."); } } else { // 抛出UserNotFoundException: throw new UserNotFoundException("User not found.",new UserNotFoundException()); }
'"admin"' 应该作为方法 "equals()"的调用方,而不是参数
程序只是方便演示
Sign in to make a reply
求女票上微博
if (username.equals("admin")) {
if (password.equals("password")) {
return "xxxxxx";
} else {
// 抛出LoginFailedException:
throw new LoginFailedException("Bad username or password.");
}
} else {
// 抛出UserNotFoundException:
throw new UserNotFoundException("User not found.",new UserNotFoundException());
}
'"admin"' 应该作为方法 "equals()"的调用方,而不是参数