myusers 的 web.xml 沒有引入什么特別的。
SSHTest 的 web.xml :
通過:
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener-->
或:
<servlet>
<servlet-name>SpringContextServlet</servlet-name>
<servlet-class>org.springframework.web.context.ContextLoaderServlet</servlet-class>
<load-on-startup>1</load-on-startup>
</servlet>
Web 容器會自動加載 /WEB-INF/applicationContext.xml 初始化 ApplicationContex t實例;
也可以通過
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/applicationContext-*.xml</param-value>
</context-param>
使 Web 容器加載指定名稱路徑的 Spring 配置文件。
myusers 的 struts-config.xml
通過
<plug-in className="org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property="contextConfigLocation"
value="/WEB-INF/applicationContext.xml,
/WEB-INF/action-servlet.xml"/>
</plug-in>
來加載 Spring 配置文件。
而 SSHTest 的 struts-config.xml 又沒有什么特別之處了。
兩個工程的 applicationContext.xml 都大同小異。
由上可以看出,即可以使用 web.xml 來使 Web 容器加載 Spring,也可以通過 struts-config.xml 來使 Web 容器加載 Spring。
是連接于:http://tb.blog.csdn.net/TrackBack.aspx?PostId=2256296
(不代表個人意思,僅供學習)