Struts2、Spring4、Hibernate4整合实例-下载


 


项目目的:
整合使用最新版本的三大框架(即Struts2、Spring4和Hibernate4)搭建项目架构原型。
项目架构原型:Struts2 + Spring4.0+ Hibernate4.2.4。
项目特色:同时使用了Struts2、Spring4、Hibernate4、log4j等库或框架,搭建一个最基本的项目原型。

加入 Spring

  • 加入Spring 所需 jar 包

    Struts2+Spring4+Hibernate4整合超详细教程

  • 配置 web.xml 文件

 

 

 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 3     xmlns="http://java.sun.com/xml/ns/javaee"
 4     xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
 5     id="WebApp_ID" version="2.5">
 6 
 7     <context-param>
 8         <param-name>contextConfigLocation</param-name>
 9         <param-value>classpath:applicationContext*.xml</param-value>
10     </context-param>
11 
12     <listener>
13         <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
14     </listener>
15 
16 
17 </web-app>

 

 

  • 加入 Spring 的配置文件[ applicationContext.xml ]
 1 <?xml version="1.0" encoding="UTF-8"?>
 2 <beans xmlns="http://www.springframework.org/schema/beans"
 3     xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
 4     xmlns:aop="http://www.springframework.org/schema/aop"
 5     xmlns:context="http://www.springframework.org/schema/context"
 6     xmlns:tx="http://www.springframework.org/schema/tx"
 7     xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd
 8         http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
 9         http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
10         http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">
11 
12 </beans>
applcationContext.xml

相关文章:

  • 2021-05-24
  • 2022-12-23
  • 2018-05-11
  • 2021-05-26
  • 2021-06-30
  • 2021-12-26
猜你喜欢
  • 2021-09-28
  • 2021-07-05
  • 2021-04-28
  • 2021-08-27
  • 2022-12-23
  • 2022-01-21
  • 2022-12-23
相关资源
相似解决方案