1

Spring が構成ファイル名を処理する場合、いくつかのデフォルトがあります...

  • DispatcherServlet を web.xml に登録すると、Spring はデフォルトで<servletname>-servlet.xmlという名前のファイルを検索します。
  • ContextLoadListener を web.xml に登録すると、Spring はデフォルトでファイル名 applicationContext.xml を検索します。

したがって、私は尋ねます:Spring Security を使用している場合、Spring はデフォルトのファイル名を検索しますか? または、常に手動で構成する必要があり<context-param> <param-name> contextConfigLocation </param-name>filename</param-value></context-param>ますか...???

4

2 に答える 2

2

Spring Security には独自のアプリケーション コンテキストがなく、ContextLoaderListener(つまりapplicationContext.xml) によって作成されたものを使用します。

したがって、Spring Security 構成をapplicationContext.xmlに配置するか、別のファイルに配置する場合は、そのファイルを からインポートする必要がありますapplicationContext.xml

<import resource = "security.xml" />

または in に加えて宣言しapplicationContext.xmlますcontextConfigLocatoion <context-param>

<context-param>
    <param-name>contextConfigLocation</param-name>
    <param-value>applicationContext.xml, security.xml</param-value>
</context-param>
于 2012-09-21T11:58:22.550 に答える
0

Spring rooはこれを行います:

  • applicationContext.xml-ルートコンテキスト
  • applicationContext-security.xml-セキュリティ構成
  • webmvc-config.xml-mvc/controllersなど
于 2012-09-21T13:48:44.770 に答える