●BeanNameUrlHandlerMapping : URL과 매칭되는 이름을 갖는 빈을 컨트롤러로 사용
    <!-- HandlerMapping -->
    <bean id="beanNameUrlHandlerMapping" class="org.springframework.web.servlet.handler.BeanNameUrlHandlerMapping"></bean>
   
    <!-- ViewResolver -->
    <bean id="internalResource" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    
    <!-- bean -->
    <bean name="/userForm.op" class="controller.UserSimpleFormController">
        <property name="formView" value="user/userForm"></property>
        <property name="successView" value="user/userSuccess"></property>
        <property name="userService" ref="userService"></property>
    </bean>

호출
http://localhost:8080/test/userForm.op



●SimpleUrlHandlerMapping : 패턴 매칭을 이용하여 다양한 URL 경로를 컨트롤러에 매칭
    <!-- HandlerMapping -->
    <bean id="simpleUrlHandlerMapping" class="org.springframework.web.servlet.handler.SimpleUrlHandlerMapping">
        <property name="mappings">
            <props>
                <prop key="/userForm.op">userController</prop>
            </props>
        </property>
    </bean>

    <!-- ViewResolver -->
    <bean id="internalResource" class="org.springframework.web.servlet.view.InternalResourceViewResolver">
        <property name="prefix" value="jsp/"></property>
        <property name="suffix" value=".jsp"></property>
    </bean>
    
    <!-- bean -->
    <bean id="userController" class="controller.UserSimpleFormController">
        <property name="formView" value="user/userForm"></property>
        <property name="successView" value="user/userSuccess"></property>
        <property name="userService" ref="userService"></property>
    </bean>


호출
http://localhost:8080/test/userForm.op




'프로그램 > Spring 2.5' 카테고리의 다른 글

HandlerMapping  (0) 2012.03.22
AOP 구현  (0) 2012.03.19
AOP(Aspect Oriented Programming) - 관점 지향 프로그래밍  (0) 2012.03.19
MultiActionController  (0) 2012.03.10
SimpleFormController  (0) 2012.03.10

+ Recent posts