- 
src/main/webapp/WEB-INF/spring/root-context.xml
 アプリケーションの共通設定として、
 ファンクション層(F層:Service)、データ層(D層:Dao)の定義を行う。- 
「@Autowire」「@Component」「@Service」のアノテーションを有効にする設定
<context:annotation-config /> 
 - 
アノテーションでScan対象とするパッケージを指定
<context:component-scan base-package="jp.co.sample.service" /> <context:component-scan base-package="jp.co.sample.dao" /> 上記パッケージにJavaファイルを配置すると、 
 JavaファイルにSpringの管理を示す「S」マークがつきます。このファイルは共通設定なので、パッケージにcontrollerが 
 格納されている場所を指定すれば「@Controller」も利用可能ですが、
 SpringMVCの考え方として、通常は「@Controller」が属するパッケージは
 後述のservlet-context.xmlに定義します。
 - 
共通設定
<beans:bean id="commonProperties" class="org.springframework.beans.factory.config.PropertiesFactoryBean"> <beans:property name="locations" value="classpath:common.properties" /> </beans:bean> 上記記述を行うことでJavaファイル内でcommon.propertiesに 
 「commonProperties」という名前でアクセスできるようになります。@Autowired private Properties commonProperties; 
 
- 
「@Autowire」「@Component」「@Service」のアノテーションを有効にする設定
- 
src/main/webapp/WEB-INF/spring/appServlet/servlet-context.xml
 プレゼンテーション層(P層:Controller)の定義を行う- 
「@Controller」のアノテーションを有効にする設定
<annotation-driven /> 
 - 
アノテーションでScan対象とするパッケージを指定
<context:component-scan base-package="jp.co.sample.controller" /> 上記パッケージにJavaファイルを配置すると、 
 JavaファイルにSpringの管理を示す「S」マークがつきます。
 - 
静的ファイルにHTTP GETリクエストが来た場合の動作定義
<resources mapping="/resources/**" location="/resources/" /> 
 - 
コントローラーの処理終了後に呼び出される画面用ファイルの指定
<beans:bean class="org.springframework.web.servlet.view.InternalResourceViewResolver"> <beans:property name="prefix" value="/WEB-INF/views/" /> <beans:property name="suffix" value=".jsp" /> </beans:bean> 
 
- 
「@Controller」のアノテーションを有効にする設定