The following are the basic configurations for integrating Hibernate and struts with spring:
1. applicationContext-ssh.xml
<? XML version = "1.0" encoding = "UTF-8"?>
<Beans xmlns = "http://www.springframework.org/schema/beans"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xmlns: Tx = "http://www.springframework.org/schema/tx"
Xmlns: AOP = "http://www.springframework.org/schema/aop"
Xmlns: context = "http://www.springframework.org/schema/context"
Xmlns: Jee = "http://www.springframework.org/schema/jee"
Xsi: schemalocation ="
Http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd
Http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd
Http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.5.xsd
Http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-2.5.xsd
Http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-2.5.xsd ">
<Bean id = "orderdao" Scope = "prototype" class = "com.tar Ena. Dao. impl. hibernateorderdao">
<Property name = "sessionfactory" ref = "sessionfactory"> </property>
</Bean>
<Bean id = "sessionfactory" class = "org. springframework. Orm. hibernate3.localsessionfactorybean">
<Property name = "datasource" ref = "mydatasource"> </property>
<Property name = "mappingresources">
<List>
<Value> com \ tarena \ pojo \ order. HBM. xml </value>
</List>
</Property>
<Property name = "hibernateproperties">
<Props>
<Prop key = "hibernate. Dilect"> org. hibernate. Dilect. mysqldilect </prop>
<Prop key = "show_ SQL"> true </prop>
<Prop key = "format_ SQL"> true </prop>
</Props>
</Property>
</Bean>
<Bean id = "mydatasource" class = "org. Apache. commons. DBCP. basicdatasource">
<Property name = "username" value = "root"> </property>
<Property name = "password" value = ""> </property>
<Property name = "driverclassname" value = "com. MySQL. JDBC. Driver"> </property>
<Property name = "url" value = "JDBC: mysql: // Dangdang"> </property>
<Property name = "maxactive" value = "15"> </property>
<Property name = "initialsize" value = "2"> </property>
</Bean>
<Bean id = "orderlistaction" class = "com.tar Ena. Action. orderlistaction" Scope = "prototype">
<Property name = "orderdao" ref = "orderdao"> </property>
</Bean>
</Beans>
2. Struts. xml
<? XML version = "1.0" encoding = "UTF-8"?>
<! Doctype struts public "-// Apache Software Foundation // DTD struts configuration 2.1 // en" "http://struts.apache.org/dtds/struts-2.1.dtd">
<Struts>
<Package name = "ssh" extends = "JSON-Default">
<Action name = "list" class = "orderlistaction">
<Result>/orderlist. jsp </result>
</Action>
</Package>
</Struts>
3. Web. xml
<? XML version = "1.0" encoding = "UTF-8"?>
<Web-app version = "2.5"
Xmlns = "http://java.sun.com/xml/ns/javaee"
Xmlns: xsi = "http://www.w3.org/2001/XMLSchema-instance"
Xsi: schemalocation = "http://java.sun.com/xml/ns/javaee
Http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd>
<Welcome-file-List>
<Welcome-File> index. jsp </welcome-File>
</Welcome-file-List>
<Context-param>
<Param-Name> contextconfiglocation </param-Name>
<Param-value> classpath: applicationContext-ssh.xml </param-value>
</Context-param>
<Listener>
<Listener-class> org. springframework. Web. Context. contextloaderlistener </listener-class>
</Listener>
<Filter>
<Filter-Name> struts2 </filter-Name>
<Filter-class>
Org. Apache. struts2.dispatcher. Ng. Filter. strutsprepareandexecutefilter
</Filter-class>
</Filter>
<Filter-mapping>
<Filter-Name> struts2 </filter-Name>
<URL-pattern>/* </url-pattern>
</Filter-mapping> </Web-app>