Notice
Recent Posts
Recent Comments
Link
투케이2K
64. (spring/스프링) ServletRequestAttributes 사용해 api 접속 요청 정보 확인 수행 실시 본문
[개발 환경 설정]
개발 툴 : inteli j
개발 언어 : spring
[소스 코드]
// [http 요청 수행 데이터 확인 실시]
String reqScheme = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getScheme();
String reqServerName = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getServerName();
String reqServerContextPath = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getContextPath();
int reqPort = ((ServletRequestAttributes) RequestContextHolder.currentRequestAttributes()).getRequest().getServerPort();
// TODO [URL 생성]
String reqUrl = reqScheme + "://" + reqServerName + ":" + String.valueOf(reqPort) + reqServerContextPath + "/LOGIN_CHECK?";
System.out.println("\n");
System.out.println("================================================");
System.out.println("[CLASS] : "+String.valueOf(CLASS_NAME));
System.out.println("[METHOD] : "+String.valueOf("PRO_INS_LOGIN"));
System.out.println("[reqScheme] : "+String.valueOf(reqScheme));
System.out.println("[reqServerName] : "+String.valueOf(reqServerName));
System.out.println("[reqPort] : "+String.valueOf(reqPort));
System.out.println("[reqServerContextPath] : "+String.valueOf(reqServerContextPath));
System.out.println("================================================");
System.out.println("\n");
[결과 출력]
반응형
'Spring' 카테고리의 다른 글
Comments