반응형

자바에서 모바일인지 아닌지 체크하는 로직 예제

 

String userAgentHeader = getRequest().getHeader("user-agent");
	if(userAgentHeader != null){
		userAgentHeader = userAgentHeader.toLowerCase();
	}
	if(userAgentHeader.matches(".*(android.+mobile|iphone|ipad|ipod|avantgo|bada\\/|blackberry|blazer|compal|elaine|fennec|hiptop|iemobile|ip(hone|od)|iris|kindle|lge |maemo|midp|mmp|opera m(ob|in)i|palm( os)?|phone|p(ixi|re)\\/|plucker|pocket|psp|symbian|treo|up\\.(browser|link)|vodafone|wap|windows (ce|phone)|xda|xiino).*")){
		getResponse().sendRedirect(Configuration.getInstance().getString("tradekorea_mobile_host"));
		return;
	}

 

 

반응형

'IT > JAVA' 카테고리의 다른 글

[JPA] Composite-id class must implement Serializable 에러  (1) 2019.05.28
[JAVA] String To Date , Date To String  (0) 2018.11.29

+ Recent posts