<aside> ➡️ 솔루션 Core의 Spring (core, webmvc) 3.2.5 를 기반으로 작성하였습니다 목차

</aside>

1. Controller

1-1. Spring의 Controller

출처: Spring Docs

출처: Spring Docs

1-2. 솔루션내에서 Controller - URL 매핑 구조 분석

  1. web.xml

    <context-param>
            <param-name>**contextConfigLocation**</param-name>
            <param-value>
    			        ....
    			        classpath:/config/**applicationContext-web.xml**
    				</param-value>
    </context-param> 
    

    web.xml에 <context-param>을 정의하여, Servlet 전역에서 사용 가능한 파라미터 값으로 등록할 수 있습니다.

    여기서 <param-name>의 contextConfigLocation는 Spring이 동작하기 위한 설정 파일의 위치를 알려주는 파라미터입니다. 해당 값으로 web 관련 설정을 관리하는 applicationContext-web.xml 을 등록합니다.

  2. applicationContext-web.xml

    
    <!-- ******************************************************************* -->
        <!-- * URL CONTROLLER MAPPING                                          * -->
        <!-- ******************************************************************* -->
        <!--
    	      for spring mvc handlerMapping..
          handlerMapping connect each controller.
        -->
    <import resource="classpath:/config/web/**webContext-controllers.xml**" />  **3-1) Bean 관련 설정 xml**
    <bean id="urlMapping" class="org.springframework.web.servlet.handler.**SimpleUrlHandlerMapping**">
            <property name="interceptors">
                <list>
                    <ref bean="localeChangeInterceptor"/>   **사용자 언어별 i18n(국제화) 다국어 처리**
    								....
                </list>
            </property>
            <property name="mappings">
                <!-- property -->
                <bean class="org.springframework.beans.factory.config.**PropertiesFactoryBean**">
                    <property name="locations">
                        <list>
                            <value>classpath:/config/web/**webContext-controllers.properties**</value>  **3) 매핑 URL 정의 properties**
    													....
                        </list>
                    </property>
                </bean> 
    
  3. webContext-controllers.properties 3) 매핑 URL 정의 properties

#------------------------------------------------------------------------------
# Main
#------------------------------------------------------------------------------
/main/main.do=mainController
/mobile/main.do=mobileController
#------------------------------------------------------------------------------
# Auth
#------------------------------------------------------------------------------
/auth/login/loginView.do=loginController
/auth/login/login.do=loginController
/auth/login/checkSessionKey.do=loginController
/auth/login/doAutoLogin.do=loginController
      ....

3-1. webContext-controllers.xml 3-1) Bean 관련 설정 xml

<!-- for parameter multiaction -->
    URL에서, 하단의 Resolver의 <value>에 해당 하는 값으로 메서드에 매핑하는 Spring 객체
    <bean id="methodNameResolver" class="org.springframework.web.servlet.mvc.multiaction.ParameterMethodNameResolver">
        <property name="paramName">
            <value>method</value>
        </property>
    </bean>

    <!--
     **************************************************************************
     * DEFAULT Controller
     **************************************************************************
     -->
    <bean name="multiActionFormController" class="destiny.framework.web.mvc.MultiActionFormController" autowire="byName" >
    </bean>
    <!--
     **************************************************************************
     * COMMON Controller
     **************************************************************************
     -->