软件编程
位置:首页>> 软件编程>> java编程>> struts+spring+hibernate三个框架的整合

struts+spring+hibernate三个框架的整合

作者:mrr  发布时间:2022-08-08 08:13:15 

标签:struts,hibernate,spring

准备三个框架结合的lib包

Spring3结合Struts2的步骤如下:

1:开启Struts2结合Spring3,在struts.xml中添加如下语句:

java代码:


<constant name="struts.objectFactory" value="spring"/>

2:在web.xml中添加listener,如下:

java代码:


<listener>
   <listener-class>
org.springframework.web.context.ContextLoaderListener</listener-class>
 </listener>

3:在web.xml中指定需要初始读取的spring配置文件,如下:

java代码:


<context-param>
 <param-name>contextConfigLocation</param-name>
 <param-value>/WEB-INF/applicationContext-*.xml,classpath*:applicationContext-*.xml</param-value>
</context-param>

5.当然别忘了加上Struts2自己的filter  

4:在struts.xml中Action配置的时候,如下:

java代码:


<action name="testAction" class="springBeanName">
 <result name="success">/index.jsp</result>
</action>

5:在Spring中正常定义Bean就可以了,把Action定义成为Bean,如下:

java代码:


<bean id="testAction" class="com.bjpowernode.test.web.TestActioin">
<property name="ebi" ref="testEbi"/>
</bean>

6:在Struts的Action中,就可以通过依赖注入的方式来注入需要使用的接口了。

总结

以上所述是小编给大家介绍的struts+spring+hibernate三个框架的整合网站的支持!

来源:http://blog.sina.com.cn/s/blog_9c6852670102ww9l.html

0
投稿

猜你喜欢

手机版 软件编程 asp之家 www.aspxhome.com