| sitelink1 | |
|---|---|
| sitelink2 | |
| sitelink3 | |
| extra_vars6 |
<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE beans PUBLIC "-//SPRING//DTD BEAN 2.0//EN" "http://www.springframework.org/dtd/spring-beans-2.0.dtd">
<!--
- DispatcherServlet application context for the Spring web MVC
- implementation of JPetStore's web tier.
-->
<beans>
<!-- ========================= VIEW DEFINITIONS ========================= -->
추후에 SITEMESH와 VELOCITY 그리고 STRUTS까지 연동해 볼 예정이다.
<bean id="viewResolver" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
<property name="viewClass" value="org.springframework.web.servlet.view.JstlView"/>
<property name="prefix" value="/WEB-INF/jsp/spring/"/>
<property name="suffix" value=".jsp"/>
</bean>
<!-- ========================= DEFINITIONS OF PUBLIC CONTROLLERS ========================= -->
이 부분은 첫번째의 BeanNameUrlHandlerMapping을 이용하여 HandlerMapping을 처리하는 부분이다.
보다 자세한 내용은 여기 를 참조하기 바란다.
<bean id="defaultHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"/>
<bean name="/shop/addItemToCart.do" class="org.springframework.samples.jpetstore.web.spring.AddItemToCartController">
<property name="petStore" ref="petStore"/>
</bean>
Controller클래스에서는 property태그에 정의된 name과 value등으로 파라미터를 전해 받는다.
<bean name="/shop/checkout.do" class="org.springframework.samples.jpetstore.web.spring.ViewCartController">
<property name="successView" value="Checkout"/>
</bean>
<bean name="/shop/index.do" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="index"/>
</bean>
<bean name="/shop/newAccount.do" class="org.springframework.samples.jpetstore.web.spring.AccountFormController">
<property name="petStore" ref="petStore"/>
<property name="validator" ref="accountValidator"/>
<property name="successView" value="index"/>
</bean>
<bean name="/shop/removeItemFromCart.do" class="org.springframework.samples.jpetstore.web.spring.RemoveItemFromCartController"/>
<bean name="/shop/signoff.do" class="org.springframework.samples.jpetstore.web.spring.SignoffController"/>
<bean name="/shop/searchProducts.do" class="org.springframework.samples.jpetstore.web.spring.SearchProductsController">
<property name="petStore" ref="petStore"/>
</bean>
<bean name="/shop/signon.do" class="org.springframework.samples.jpetstore.web.spring.SignonController">
<property name="petStore" ref="petStore"/>
</bean>
<bean name="/shop/signonForm.do" class="org.springframework.web.servlet.mvc.ParameterizableViewController">
<property name="viewName" value="SignonForm"/>
</bean>
<bean name="/shop/updateCartQuantities.do" class="org.springframework.samples.jpetstore.web.spring.UpdateCartQuantitiesController"/>
<bean name="/shop/viewCart.do" class="org.springframework.samples.jpetstore.web.spring.ViewCartController">
<property name="successView" value="Cart"/>
</bean>
<bean name="/shop/viewCategory.do" class="org.springframework.samples.jpetstore.web.spring.ViewCategoryController">
<property name="petStore" ref="petStore"/>
</bean>
<bean name="/shop/viewItem.do" class="org.springframework.samples.jpetstore.web.spring.ViewItemController">
<property name="petStore" ref="petStore"/>
</bean>
<bean name="/shop/viewProduct.do" class="org.springframework.samples.jpetstore.web.spring.ViewProductController">
<property name="petStore" ref="petStore"/>
</bean>
<!-- ========================= DEFINITIONS OF PROTECTED CONTROLLERS ========================= -->
<bean id="secureHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
<property name="interceptors">
<list>
<ref bean="signonInterceptor"/>
</list>
</property>
<property name="urlMap">
<map>
<entry key="/shop/editAccount.do" value-ref="secure_editAccount"/>
<entry key="/shop/listOrders.do" value-ref="secure_listOrders"/>
<entry key="/shop/newOrder.do" value-ref="secure_newOrder"/>
<entry key="/shop/viewOrder.do" value-ref="secure_viewOrder"/>
</map>
</property>
key가 요청url이고 value-ref가 실행될 Controller를 나타낸다.
value-ref에 정의된 Controller들은 하단부에 정의되어 있다.
</bean>
<bean id="signonInterceptor" class="org.springframework.samples.jpetstore.web.spring.SignonInterceptor"/>
단지 코드를 보면 userSession이 있는지 없는지에 따라 로그인 상태 여부를 검사하고 있다.
http://openframework.or.kr/framework_reference/spring/ver2.x/html/mvc.html#mvc-handlermapping-interceptor
여기서 HandlerInterceptor인터페이스의 쓰임새를 공부하자.
<bean id="secure_editAccount" class="org.springframework.samples.jpetstore.web.spring.AccountFormController">
<property name="petStore" ref="petStore"/>
<property name="validator" ref="accountValidator"/>
<property name="successView" value="index"/>
</bean>
<bean id="secure_listOrders" class="org.springframework.samples.jpetstore.web.spring.ListOrdersController">
<property name="petStore" ref="petStore"/>
</bean>
<bean id="secure_newOrder" class="org.springframework.samples.jpetstore.web.spring.OrderFormController">
<property name="petStore" ref="petStore"/>
<property name="validator" ref="orderValidator"/>
</bean>
<bean id="secure_viewOrder" class="org.springframework.samples.jpetstore.web.spring.ViewOrderController">
<property name="petStore" ref="petStore"/>
</bean>
</beans>
댓글 0
| 번호 | 제목 | 글쓴이 | 날짜 | 조회 수 |
|---|---|---|---|---|
| 9 |
실습 STEP2 - 기초편 (데이터 베이스 접속)
| 황제낙엽 | 2007.06.21 | 244 |
| 8 |
실습 STEP1 - 기초편 (Hello Spring 출력)
| 황제낙엽 | 2007.04.27 | 258 |
| 7 |
Cugain의 샘플프로젝트 jpetstore 분석기 - (1) jpetstore 설치
| 황제낙엽 | 2007.02.22 | 352 |
| 6 | Cugain의 샘플프로젝트 jpetstore 분석기 - (7) PetStoreImpl.java | 황제낙엽 | 2007.05.24 | 232 |
| » | Cugain의 샘플프로젝트 jpetstore 분석기 - (6) petstore-servlet.xml 분석 | 황제낙엽 | 2007.04.27 | 203 |
| 4 | Cugain의 샘플프로젝트 jpetstore 분석기 - (5) applicationContext.xml 분석 | 황제낙엽 | 2007.04.21 | 438 |
| 3 | Cugain의 샘플프로젝트 jpetstore 분석기 - (4) dataAccessContext-jta.xml 분석 | 황제낙엽 | 2007.04.21 | 224 |
| 2 | Cugain의 샘플프로젝트 jpetstore 분석기 - (3) dataAccessContext-local.xml 분석 | 황제낙엽 | 2007.04.21 | 235 |
| 1 | Cugain의 샘플프로젝트 jpetstore 분석기 - (2) web.xml 분석 | 황제낙엽 | 2007.03.20 | 301 |
