2011-06-29 6 views
3
<context:exclude-filter type="aspectj" expression="com.myapp.controller.*"/> 

下記のapplicationContext.xmlファイルの上記の行の目的は、Spring MVC Webアプリケーションの設定に使用されますか?Spring MVCコントローラパッケージのコンフィグレーションに適用される<context:exclude-filter>の目的は何ですか?

<beans xmlns="http://www.springframework.org/schema/beans" 
    xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" 
    xmlns:context="http://www.springframework.org/schema/context" 
    xsi:schemaLocation="http://www.springframework.org/schema/beans 
     http://www.springframework.org/schema/beans/spring-beans-3.0.xsd 
     http://www.springframework.org/schema/context 
     http://www.springframework.org/schema/context/spring-context-3.0.xsd"> 

    <context:annotation-config /> 
    <context:component-scan base-package="com.myapp"> 
     <context:exclude-filter type="aspectj" expression="com.myapp.controller.*"/> 
    </context:component-scan> 

    <import resource="applicationContext-data.xml" /> 
    <import resource="applicationContext-security.xml" /> 
    <import resource="applicationContext-service.xml" /> 

</beans> 

答えて

3

これは@Lucianoは前記したものの上に追加され、典型的には春MVCアプリケーションの良い方法は、(ContextLoaderListenerによって読み込ま)スプリングコアコンテキストコンフィギュレーションを維持することであり、別個の(DispatcherServletを介してロードされた)プレゼンテーション層構成。この特定の例では、明示的にコントローラを除外しているコアコンテキストファイルが表示されています。これは、DispatcherServletがロードされたSpring設定ファイルとともに明示的に定義されている可能性があります。

2

それはcom.myapp.controllerパッケージとサブパッケージに存在することができるコンポーネント(春注釈付きクラス)を除外するために春を教えてくれます。おそらく、このWebアプリケーションの責任者がアクティブにしたくないというコントローラがあります。

com.myappの下にある残りのコンポーネントがロードされ、設定されます。

関連する問題