Spring struts2 hibernate 整合

来源:互联网 发布:制作网站的软件 编辑:程序博客网 时间:2024/05/02 02:07

整合的时候,Spring管理hibernate的sessionfactory,struts2的action。当然action有时候是有状态的,有时候无状态,可在Spring配置里加入scope="singleton"或者scope="prototype"。

 

现在看看如何配置。

配置WEB.XML(添加上struts2的过滤器和Spring的监听器)

 

配置Spring文件applicationContext.xml(IOC管理了Action,Sessionfactory,Bean),Spring文件已经将hibernate的信息都配置了,所以hibernate.cfg.xml可以为空白的

 

配置struts2文件struts.xml

 

原创粉丝点击