웹 프로젝트에서 모바일 기능을 사용하고 싶습니다.
Question is closed for new answers.
이 상현 Selected answer as best 2022년 07월 18일
jsp 기반으로 web, mobile 환경을 사용하는 webApp 형식의 가이드 입니다.
legacy 웹 프로젝트를 기준으로 변경할 사항을 정리하고 밑에 mobile 프로젝트와의 차이점을 명시
pom.xml
- 캐모마일 모바일 의존성 추가
..... <dependency> <groupId>net.lotte.chamomile</groupId> <artifactId>chamomile-mobile</artifactId> </dependency> .....
web.xml
src/main/webapp/WEB-INF/web.xml
..... <!-- local web -> local was 시 적용되는 CORS 필터. security 필터보다 선행되어야 한다. web 서버 - was 서버로 구성된 개발,운영 환경에서는 해당 필터가 필요 없다. --> <filter> <filter-name>CorsFilter</filter-name> <filter-class>net.lotte.chamomile.mobile.web.filter.MobileCorsFilter</filter-class> </filter> <filter-mapping> <filter-name>CorsFilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> .....
- 모바일 프로젝트와의 차이점: MobileFilter 사용 안함
- 제약사항: 캐모마일 모바일 코어 js 통신 라이브러리 비즈니스 Controller req, resp 자동 적용 제외
context-servlet.xml
src/main/webapp/WEB-INF/spring/context-servlet.xml
- 컴포넌트 스캔에 mobile 관련 controller 추가 : “net.lotte.chamomile.mobile”
..... <context:component-scan base-package="net.lotte.sample, net.lotte.chamomile.api, net.lotte.chamomile.mobile"> <context:include-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> .....
-
- 모마일 실행환경 앱 정보 스케쥴러 추가
..... <!-- task 정의 추가 --> xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd ..... <!-- 모바일 실행환경 앱 모니터링 정보 수집 시 @async , @Scheduled 사용을 위한 annotation-driven 설정. 실제 mobileExecutor 는 app context에 설정 @See context-mobile.xml --> <task:annotation-driven executor="mobileExecutor" scheduler="taskScheduler"/>
-
- 모바일 인터셉터 추가
<interceptors> <!-- mobile실행환경 인터셉터 --> <interceptor> <mapping path="/**"></mapping> <exclude-mapping path="/resources/**"/> <exclude-mapping path="/admin/**" /> <exclude-mapping path="/mobilecore/**" /> <beans:bean class="net.lotte.chamomile.mobile.web.filter.MobileCommonInterceptor" /> </interceptor> </interceptors>
context-mobile.xml
<?xml version="1.0" encoding="UTF-8"?> <beans xmlns="http://www.springframework.org/schema/beans" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:p="http://www.springframework.org/schema/p" xmlns:context="http://www.springframework.org/schema/context" xmlns:aop="http://www.springframework.org/schema/aop" xmlns:task="http://www.springframework.org/schema/task" xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd http://www.springframework.org/schema/task http://www.springframework.org/schema/task/spring-task.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd"> <!-- mobile component스캔 --> <context:component-scan base-package="net.lotte.chamomile.mobile"> <context:exclude-filter type="annotation" expression="org.springframework.stereotype.Controller" /> </context:component-scan> <!-- mobile mybatis 스캔 --> <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer"> <property name="basePackage" value="net.lotte.chamomile.mobile" /> <property name="annotationClass" value="org.apache.ibatis.annotations.Mapper" /> </bean> <!-- 앱 모니터링 정보 수집 시 async 사용을 위한 executor 설정 --> <bean id="mobileExecutor" class="org.springframework.scheduling.concurrent.ThreadPoolTaskExecutor"> <property name="corePoolSize" value="30" /> </bean> </beans>
context-security.xml
- 모바일 관련 API 시큐리티 제외
..... <http pattern="/mobilecore/**" security="none" /> .....
- 모바일 프로젝트와의 차이점 : 모바일 디바이스에서 하이브리드 웹앱 기반 JSON 로그인, 로그아웃 기능 제외
- 제약 사항 : PC 플랫폼과 동일한 로그인 화면을 사용할 경우 자동 로그인 등 기능 등 요건 확인 필요
이 상현 Selected answer as best 2022년 07월 18일