如果是在struts-config.xml中直接寫為 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn"/> ,則是默認配置文件為在WEB-INF下的action-servlet.xml文件,可在action-servlet.xml中再截入各個action bean的配置,如<import resource="modules/spring-config-login.xml"/>等。
另外service的配置和applicationContext.xml或sping相關(guān)的數(shù)據(jù)庫文件,可自己建立一個目錄,然后在web.xml中加載 <context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:spring/*.xml</param-value>
</context-param>
這樣將web層和service層的配置分開擺放,看起來比較清晰。具體可參考springside的example
另一方法是struts-config中直接寫 <plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation" value="classpath*:spring/*.xml"/>
</plug-in>
這樣將所有的配置文件直接放在spring目錄下
或小型應(yīng)用可簡單寫成最直接的<plug-in className= "org.springframework.web.struts.ContextLoaderPlugIn"> <set-property property= "contextConfigLocation" value="/WEB-INF/applicationContext.xml"/>
不過多句提醒下記得不要漏了web.xml中還應(yīng)有 <listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
struts-config.xml中還應(yīng)有:
<controller>
<set-property property="processorClass" value="org.springframework.web.struts.DelegatingRequestProcessor"/>
</controller>
posted on 2007-06-15 12:16
lzj520 閱讀(265)
評論(0) 編輯 收藏 所屬分類:
Spring 、
個人學習日記