@Override
public Authentication attemptAuthentication (HttpServletRequest request, HttpServletResponse response) throws AuthenticationException {
try{
LoginRequestDto requestDto = new LoginRequestDto(request.getParameter("email"), request.getParameter("password"));
return getAuthenticationManager().authenticate(
new UsernamePasswordAuthenticationToken(
requestDto.getEmail(),
requestDto.getPassword(),
null
)
);
}catch (Exception e){
throw new RuntimeException(e.getMessage());
}
}
위 코드를 보면 유저 로그인 확인하는 필터의 코드인데 attemptAuthentication 메소드를 재정의 해서 사용한다.
조건
사용 목적
class OverloadingTest{
//이름이 cat인 메서드
void cat(){
System.out.println("매개변수 없음");
}
//매개변수 int형이 2개인 cat 메서드
void cat(int a, int b){
System.out.println("매개변수 :"+a+", "+b);
}
//매개변수 String형이 한 개인 cat 메서드
void cat(String c){
System.out.println("매개변수 : "+ c);
}
}
public class OverTest {
public static void main(String[] args) {
//OverloadingTest 객체 생성
OverloadingTest ot = new OverloadingTest();
//매개변수가 없는 cat() 호출
ot.cat();
//매개변수가 int형 두개인 cat() 호출
ot.cat(20, 80);
//매개변수가 String 한개인 cat() 호출
ot.cat("오버로딩 예제입니다.");
}
}
조건 :
장점