Original: SSH2 Frame construction
struts2+spring4.0+hibernate4.0
The 4.x version and the 3.x version have a large difference, to configure the method need to be aware that the use of the jar package is as follows
File structure
Src/applicationcontext.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" xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "> <!--transaction manager, delegating to Hibernatetransactionmana GER is managed//-<bean id= "TransactionManager" class= "org.springframework.orm.hibernate4.HibernateTransacti Onmanager "> <property name=" sessionfactory "ref=" Sessionfactory "/> </bean> <!--AOP configuration for transaction processing All service layer bean declarations inherit this bean, and the target property is not defined in the proxy, so be sure to add abstract= "true"/---<bean id= "to the Bean" transactionproxyt Emplate "abstract=" true "class=" Org.springframework.transaction.interceptor.TransactionProxyFactoryBean "> <property name= "TransactionManager" ref= "TransactionManager"/> <property name= "TransactionAttributes" &G T <props> <!--to ensure uniform transaction processing for the service layer. Service layer interface, the class method must start with the following method--<!--spring catches to runtimeexception and some other exceptions when it is rolled back, not all exceptions will be rolled back,-exception set to any exception Roll-<prop key= "get*" >PROPAGATION_REQUIRED,readOnly</prop> <prop key= "fin d* ">PROPAGATION_REQUIRED,readOnly</prop> <prop key=" query* ">propagation_required,readonly< ;/prop> <prop key= "load*" >PROPAGATION_REQUIRED,readOnly</prop> <prop key= " user* ">PROPAGATION_REQUIRED,readOnly</prop> <prop key=" save* ">propagation_required,-exceptio n</prop> <prop key= "insert*" >PROPAGATION_REQUIRED,-Exception</prop> <PR Op key= "add*" >PROPAGATION_REQUIRED,-Exception</prop> <prop key= "up*" >propagation_required,-e xception</prop> <prop key= "mod*" >PROPAGATION_REQUIRED,-Exception</prop> <prop key= "del*" >PROPAGATION_REQUIRED,-Exception</prop> <prop key= "remove*" >PR opagation_required,-exception</prop> <prop key= "create*" >PROPAGATION_REQUIRED,-EXCEPTION</PR op> <prop key= "execute*" >PROPAGATION_REQUIRED,-Exception</prop> <prop key= "do*" >PROPAGATION_REQUIRED,-Exception</prop> </props> </property> </bean> <!--provides the general Java class get the spring context to get the specific bean through the context, calling the method in it-<bean id= "Springapplicationcontextutil" class= "Com.soyan N.common.util.springapplicationcontextutil "></bean> <!--when the system is initialized read database configuration file configuration database type--<bean clas s= "Com.soyann.common.util.DBPropertiesUtil" lazy-init= "false" init-method= "Init"/> <!-- Get Nextval--<bean id= "Mysqlkeygenerator" class= "Org.springframework.jdbc.support.inc" based on MySQL database identity Rementer. Mysqlmaxvalueincrementer "> <Property Name= "DataSource" ref= "Sysdatasource"/> <property name= "Incrementername" > <value> ;sy_key_sequence</value> </property> <property name= "ColumnName" > <value> Id</value> </property> </bean></beans>
Src/applicationcontext-db
<?xml version= "1.0" encoding= "UTF-8"? ><beans xmlns= "Http://www.springframework.org/schema/beans" xmlns: Xsi= "Http://www.w3.org/2001/XMLSchema-instance" xsi:schemalocation= "Http://www.springframework.org/schema/beans Http://www.springframework.org/schema/beans/spring-beans-3.0.xsd "><bean id=" Propertyconfigure "class=" Org.springframework.beans.factory.config.PropertyPlaceholderConfigurer "><property name=" Locations "> <list><value>classpath:resource/properties/dbconfig.properties</value></list></ property></bean><!--Specify the driver--><bean id= "Sysdatasource" class= "to connect to the database Com.mchange.v2.c3p0.ComboPooledDataSource "destroy-method=" Close "><!--the driver class name-->< Property Name= "Driverclass" ><value>${jdbc.driverClassName}</value></property><!-- Specify the URL of the connection database--><property name= "Jdbcurl" ><value>${jdbc.url}</value></property><!-- Specifies the user name of the connection database--><property name= "User ><value>${jdbc.username}</value></property><!--Specify the password to connect to the database--><property name= " Password "><value>${jdbc.password}</value></property><!--the number of initialized connections for the specified connection pool should be in minpoolsize and Between the maxpoolsize. Default:3--><property name= "Initialpoolsize" ><value>${jdbc.initialpoolsize}</value></ property><!--Maximum idle time, unused in 60 seconds, the connection is discarded. If 0, it will never be discarded. default:0--><property name= "MaxIdleTime" ><value>60</value></property></bean> <bean id= "Sessionfactory" class= "Org.springframework.orm.hibernate4.LocalSessionFactoryBean" ><property Name= "DataSource" ><ref bean= "Sysdatasource"/></property><property name= "Hibernateproperties" ><props><prop key= "Hibernate.dialect" >${hibernate.dialect}</prop><prop key= " Hibernate.show_sql ">${hibernate.show_sql}</prop><prop key=" Hibernate.cache.region.factory_class " >${hibernate.cache.region.factory_class}</prop><Prop key= "Hibernate.cache.use_query_cache" >${hibernate.cache.use_query_cache}</prop><prop key= " Hibernate.jdbc.batch_size ">${hibernate.jdbc.batch_size}</prop><prop key=" Hibernate.connection.url " >jdbc:mysql://192.168.8.100:3306/soyann</prop><prop key= "Hibernate.connection.driver_class" > com.mysql.jdbc.driver</prop></props></property><!--Folder Map--<property name= " Mappingdirectorylocations "> <list> <value>WEB-INF/classes/com/soyann</value> </list> </property><!--Annotated Way Map--<property name= "Packagestoscan" > <list> <value>com.soyann.* </value> </list></property></bean></beans>
Web. XML
<?xml version= "1.0" encoding= "UTF-8"? ><web-app xmlns= "Http://xmlns.jcp.org/xml/ns/javaee" xmlns:xsi= "http ://www.w3.org/2001/XMLSchema-instance "xsi:schemalocation=" Http://xmlns.jcp.org/xml/ns/javaee/http Xmlns.jcp.org/xml/ns/javaee/web-app_3_1.xsd "version=" 3.1 "> <display-name>sshframe</display-name> ; <context-param> <param-name>webAppRootKey</param-name> <param-value>sshframe.root< ;/param-value> </context-param> <context-param> <param-name>contextconfiglocation</pa ram-name> <param-value> classpath:resource/spring/**/app*.xml </param-value> &L t;/context-param> <context-param> <param-name>log4jConfigLocation</param-name> <p Aram-value>/web-inf/classes/resource/properties/log4j.properties</param-value> </context-param> <listener> <listener-Class>org.springframework.web.util.log4jconfiglistener</listener-class> </listener> <listener > <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </lis tener> <filter> <filter-name>CharacterEncodingFilter</filter-name> <filter-class& Gt;org.springframework.web.filter.characterencodingfilter</filter-class> <init-param> <pa Ram-name>encoding</param-name> <param-value>UTF-8</param-value> </init-param> <init-param> <param-name>forceEncoding</param-name> <param-value>tru e</param-value> </init-param> </filter> <filter-mapping> <filter-name>ch Aracterencodingfilter</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> & Lt;filter> <filtEr-name>cleanup</filter-name> <filter-class>org.apache.struts2.dispatcher.actioncontextcleanup </filter-class> </filter> <filter-mapping> <filter-name>cleanup</filter-name> <url-pattern>/*</url-pattern> </filter-mapping> <filter> <filter-name>str Uts2</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>
More code: http://download.csdn.net/detail/neil89/8822091
SSH2 Frame Construction