周建国 leo821031@gmail.com
Struts-Hibernate-Spring 推荐的最优组合配置
申明:以下仅供参考
开始之前先了解下一些概念:
MVC:数据模型层,显示层,逻辑控制层
VO:值对象
PO:持久对象
IOC:依赖注入(反转控制)
AOP:面向方面
一. Struts 与 Spring 的组合
Struts 与 Spring 的组合主要理解为如何将 Struts 应用程序整合进 Spring 中,就是将 Struts
应用程序导入 Spring 框架,使得 Spring 管理 Struts 动作就像管理 Spring beans 那样.
将一个 Struts 应用程序整合进 Spring 框架具有多方面的优点,具体分 3 种实现方式:
1. 使用 Spring 的 ActionSupport 类整合 Structs
2. 使用 Spring 的 DelegatingRequestProcessor 覆盖 Struts 的 RequestProcessor
3. 将 Struts Action 管理委托给 Spring 框架
实施细节:
以上 3 种组合都需要在 struts-config.xml(前提是在 web.xml 中预先加载这个配置文件,当然
struts-config.xml 这 个 文 件 自 己 随 便 可 以 定 义 , 只 要 遵 循 struts-config_1_2.dtd, 比 如
struts-config-example.xml)中进行一个配置,加载一个插件 ContextLoaderPlugIn
struts-config.xml 里的插件配置
<plug-in className=
"org.springframework.web.struts.ContextLoaderPlugIn">
<set-property property=
"contextConfigLocation" value="/WEB-INF/beans.xml"/>
</plug-in>
既然在 struts-config.xml 中已经配置了,那么无需再在 web.xml 中配置 applicationContext.xml
web.xml 里的配置
<!--已经在sturts-config.xml中配置了applicationContext.xml那么请把web.xml加载的
applicationContext这段注释掉-->
<!-->context-param>
<param-name>applicationContext</param-name>
<param-value>/src/applicationContext.xml</param-value>
</context-param-->
<!-- servlet2.3以上 -->
<!--listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener-->
<!—使用了servlet2.3,就不需要ContextLoaderServlet,它用来兼容servlet2.3以下 -->
<!-- servlet>
<servlet-name>SpringContextServlet</servlet-name>
1
数字签名人 Lucifer
DN:cn=Lucifer,c=CN-中
国,o=China telecom,
ou=software department,
email=leo821031@gmail
.com
原因:我是该文档的作者
位置:上海
日期:2006.10.22
11:58:41 +08'00'
评论1