struts+spring+hibernate三个框架的整合
作者:mrr 时间:2022-08-08 08:13:15
准备三个框架结合的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
标签:struts,hibernate,spring
![](/images/zang.png)
![](/images/jiucuo.png)
猜你喜欢
macOS下Spring Boot开发环境搭建教程
2023-11-05 15:50:59
![](https://img.aspxhome.com/file/2023/1/85541_0s.jpg)
Spring整合WebSocket应用示例(上)
2023-05-05 10:09:21
Spring-AOP @AspectJ进阶之如何绑定代理对象
2022-05-31 16:08:38
![](https://img.aspxhome.com/file/2023/8/72388_0s.jpg)
IDEA 端口占用的解决方法(推荐)
2023-09-05 06:05:15
![](https://img.aspxhome.com/file/2023/6/116116_0s.png)
解决RestTemplate 请求url中包含百分号 会被转义成25的问题
2022-11-01 22:59:51
Java集合删除元素ArrayList实例详解
2022-11-09 19:12:39
![](https://img.aspxhome.com/file/2023/0/69310_0s.png)
java 交换两个数据的方法实例详解
2021-12-06 00:56:04
如何使用ByteArrayOutputStream下载文件
2021-07-29 11:32:45
简单谈谈Java 中的线程的几种状态
2023-05-10 13:29:45
java初学者必须理解这几个问题
2023-04-07 14:22:36
flutter实现发送验证码功能
2023-07-05 19:03:12
![](https://img.aspxhome.com/file/2023/3/90173_0s.jpg)
SpringBoot配置拦 截器实现过程详解
2023-11-24 17:14:58
SpringBoot与Angular2的集成示例
2021-09-02 22:24:55
C#抽象类与抽象方法详解
2022-05-20 18:08:03
![](https://img.aspxhome.com/file/2023/0/96420_0s.jpg)
深入解析kafka 架构原理
2023-11-18 13:40:14
![](https://img.aspxhome.com/file/2023/7/75457_0s.jpg)
安卓(Android)游戏开发音效代码
2023-11-15 14:47:58
Java如何跳出当前多重循环你知道吗
2022-12-17 02:22:17
Idea运行单个main方法,不编译整个工程的问题
2021-09-06 09:57:22
![](https://img.aspxhome.com/file/2023/9/79849_0s.jpg)
Flow转LiveData数据丢失原理详解
2023-05-20 10:22:25
![](https://img.aspxhome.com/file/2023/1/96761_0s.jpg)
SpringBoot使用Thymeleaf自定义标签的实例代码
2023-11-24 21:41:29