스프링 간단 개발 가이드
2010. 7. 29. 18:51ㆍ컴퓨터 프로그램/JAVA
스프링 간단 개발 가이드
WebContent/WEB-INF/dispatcher-servlet.xml Controller bean 등록
1. 맵핑 프로퍼티에 프로그램 컨트롤러를 추가등록한다.
<property name="mappings">
<props>
<prop key="/chumdan_src/offer.*">offerViewController</prop> <-- 컨트롤러 추가
</props>
</property>
<property name="mappings">
<props>
<prop key="/chumdan_src/offer.*">offerViewController</prop> <-- 컨트롤러 추가
</props>
</property>
2. beans에 해당 프로그램의 클래스와 서비스 프로퍼티를 추가등록한다.
그리고 해당 클래스를 생성한다.
<bean id="offerViewController" class="com.kisc.controller.OfferViewController">
<property name="siteService" ref="siteService" />
<property name="menuService" ref="menuService" />
<property name="offerService" ref="offerService" /> <-- 서비스 추가
</bean>
그리고 해당 클래스를 생성한다.
<bean id="offerViewController" class="com.kisc.controller.OfferViewController">
<property name="siteService" ref="siteService" />
<property name="menuService" ref="menuService" />
<property name="offerService" ref="offerService" /> <-- 서비스 추가
</bean>
3. applicationContext-contents.xml에 dispatcher-servlet.xml에서 추가한 서비스를 등록한다.
또한 bean 등록시 아이바티즈의 프로퍼티를 추가한다. 마찬가지로 해당 클래스를 생성한다.
<bean id="offerDAO" class="com.chumdan.offer.OfferDAOImpl">
<property name="sqlMapClient" ref="sqlMapClient"/> <-- 아이바티즈 설정을 등록
</bean>
<bean id="offerService" class="com.chumdan.offer.OfferServiceImpl">
<property name="offerDAO" ref="offerDAO"/> <-- 아이바티즈 설정을 등록
</bean>
또한 bean 등록시 아이바티즈의 프로퍼티를 추가한다. 마찬가지로 해당 클래스를 생성한다.
<bean id="offerDAO" class="com.chumdan.offer.OfferDAOImpl">
<property name="sqlMapClient" ref="sqlMapClient"/> <-- 아이바티즈 설정을 등록
</bean>
<bean id="offerService" class="com.chumdan.offer.OfferServiceImpl">
<property name="offerDAO" ref="offerDAO"/> <-- 아이바티즈 설정을 등록
</bean>
4. SqlMapConfig.xml에 DB 쿼리 XML 파일을 추가로 등록한다.
<sqlMap resource="sql/program_offer.xml" />
<sqlMap resource="sql/program_offer.xml" />
5. sql/ 디렉토리에 아이바티즈 XML 파일을 기술한다.