[Spring] 브라우저 별 확인법

hyewon jeong·2024년 2월 5일
0

Spring

목록 보기
53/59
@PostMapping
@ResponseBody
public void fildDownload(HttpServletRequest request,HttpServletResponse response){

   String userAgent = request.getHeader("User-agent").toLowerCase();
   
   // 익스플로러 확인
   if(userAgent.indexOf("msie")> -1 || userAgent.indexOf("rv:11") > -1){
	System.out.println("인터넷 익스플로러 브라우저 입니다. ");
   }
   
   // 크롬 확인
   if(userAgent.indexOf("chrome")> -1 ){
	System.out.println("크롬 브라우저 입니다. ");
   }
   
   // 사파리 확인
   if(userAgent.indexOf("safari") > -1 ){
	System.out.println("사파리 브라우저 입니다. ");
   }
   
   // 파이어폭스 확인
   if(userAgent.indexOf("firefox") > -1 ){
	System.out.println("파이어폭스 브라우저 입니다. ");
   }
}

참고
https://wrkbr.tistory.com/542

profile
개발자꿈나무

1개의 댓글

comment-user-thumbnail
2024년 2월 5일

꾸준하신 모습 머찝니당 ㅎㅎㅎ

답글 달기