테스트사양

 - API 버전 : 1.1.5

 - 프레임워크 : SPRING 5

 - 개발툴(IDE) : 이클립스(Eclupse STS Oxygen.3a)

 - 빌드(Build) : Maven

 - 일자 : 2018.10.12



1. 메이븐(pom.xml)

<dependency>     <groupId>org.springframework.mobile</groupId>     <artifactId>spring-mobile-device</artifactId>     <version>1.1.5.RELEASE</version> </dependency>

참조 : https://mvnrepository.com/artifact/org.springframework.mobile/spring-mobile-device



2. mvc-config.xml(interceptors)

<mvc:interceptors>     <mvc:interceptor>         <mvc:mapping path="/**"/>

<bean class="org.springframework.mobile.device.DeviceResolverHandlerInterceptor"></bean>

</mvc:interceptor>

</mvc:interceptors>

※ mvc 접두어는 자신에 맞추어 조절!



3. web.xml

<filter>

<filter-name>deviceResolverRequestFilter</filter-name>

<filter-class>org.springframework.mobile.device.DeviceResolverRequestFilter</filter-class>

</filter>


4. mvc-config.xml(annotation-driven)

<mvc:annotation-driven>     <mvc:argument-resolvers>         <bean class="org.springframework.mobile.device.DeviceWebArgumentResolver" />     </mvc:argument-resolvers> </mvc:annotation-driven>

※ mvc 접두어는 자신에 맞추어 조절!



5. Java 콘솔 확인

if (device.isMobile()) {     logger.info("Hello mobile user!"); } else if (device.isTablet()) {     logger.info("Hello tablet user!"); } else {     logger.info("Hello desktop user!"); }

※ 타블렛이랑 모바일은 반응형으로 한번에 하는 게 좋을듯!


그리고 새삼 느끼지만 원문 사이트를 보면 정말 잘 나와 있다!

원문링크 : https://docs.spring.io/spring-mobile/docs/current/reference/html/device.html


블로그 이미지

촌놈 개발자 일기

개발자로서 살아가는 느낌과 정보를 공유 합니다

,