struts1.x部分
struts.config.xml
<?xml version="1.0" encoding="ISO-8859-1" ?>
<!DOCTYPE struts-config PUBLIC
"-//Apache Software Foundation//DTD Struts Configuration 1.2//EN"
"http://jakarta.apache.org/struts/dtds/struts-config_1_2.dtd">
<struts-config>
<message-resources parameter="MessageResources" />
</struts-config>
web.xml部分
<?xml version="1.0" encoding="UTF-8"?>
<web-app version="2.4"
xmlns="http://java.sun.com/xml/ns/j2ee"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://java.sun.com/xml/ns/j2ee
http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd">
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>
<servlet>
<servlet-name>action</servlet-name>
<servlet-class>org.apache.struts.action.ActionServlet</servlet-class>
<init-param>
<param-name>config</param-name>
<param-value>/WEB-INF/struts-config.xml</param-value>
</init-param>
<init-param>
<param-name>debug</param-name>
<param-value>2</param-value>
</init-param>
<init-param>
<param-name>detail</param-name>
<param-value>2</param-value>
</init-param>
<load-on-startup>2</load-on-startup>
</servlet>
<!-- Standard Action Servlet Mapping -->
<servlet-mapping>
<servlet-name>action</servlet-name>
<url-pattern>*.do</url-pattern>
</servlet-mapping>
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath*:applicationContext-*.xml</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>
<filter>
hibernate部分
hibernate.cfg.xml
<!DOCTYPE hibernate-configuration PUBLIC
"-//Hibernate/Hibernate Configuration DTD 3.0//EN"
"http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">
<hibernate-configuration>
<session-factory>
<property name="hibernate.connection.url">jdbc:mysql://localhost/spring_struts_hibernate</property>
<property name="hibernate.connection.driver_class">com.mysql.jdbc.Driver</property>
<property name="hibernate.connection.username">root</property>
<property name="hibernate.connection.password">bjsxt</property>
<property name="hibernate.dialect">org.hibernate.dialect.MySQLDialect</property>
<property name="hibernate.show_sql">true</property>
<property name="hibernate.hbm2ddl.auto">update</property>
</session-factory>
</hibernate-configuration>
spring
部分
<?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:aop="http://www.springframework.org/schema/aop"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-2.0.xsd
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.0.xsd">
<!-- 配置sessionFactory -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>
<!-- 配置事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>
<!-- 配置事务的传播特性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="del*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>
<!-- 那些类的哪些方法参与事务 -->
<aop:config>
<aop:pointcut id="allManagerMethod" expression="execution(* xxx.xxx.*.*(..))"/>
<aop:advisor pointcut-ref="allManagerMethod" advice-ref="txAdvice"/>
</aop:config>
</beans>
分享到:
相关推荐
spring,struts2,hibernate三个框架简称SSH框架整合包3.x,包括一个ssh整合Demo,还有三个框架的xml文件的配置,还有所需要的jar包,也有全部的jar包。
此处提供三个文档,有用配置文件直接配的,有借助eclipse工具生成的,对最近的Struts+Spring+Hibernate进行带图文的详细整合接受,此文档由本人进行整理,希望对大家有所帮助。
事务声明在Dao中,但是通常都会在Service中来处理多个业务逻辑的关系,如:删除,更新等,此时如果在执行了一个步骤之后抛出抛出异常就会导致数据部完整,所以事务不应该在Dao中处理,而应该在Service中处理,这也是...
org.springframework.web-x.x.x.RELEASE.jar:在web.xml中配置启动Spring容器所需,包括上下文和监听器。 Struts2相关的jar包: Struts2的核心库,如struts2-core-x.x.x.jar。 以及其他与Struts2相关的库,例如用于...
1、Spring 3.x 对 Hibernate 4.x 不提供 HibernateDaoSupport,所以在dao的实现层注入SessionFactory 2、报错:org.hibernate.HibernateException: No Session found for current thread 意思是必须在...
1.掌握Struts1.x的导包及配置;Struts1.x结合JSP实现视图层的应用;2.掌握Struts2.x的导包及配置;Struts2.x结合JSP实现视图层的应用;3.掌握Hibernate的导包及配置;Hibernate结合JSP实现...5.SSH整合的配置及应用
8.slf4j-nop-1.6.4.jar(对slf4j-api-x.x.x.jar的一个实现) 9.ojdbc14.jar (oracle驱动) 10.mysql-connector-java-5.1.6-bin.jar (mySql驱动) 如果使用注解还需添加hibernate-annotations-3.4.0.GA包: 11....
jar包 包括: struts2 - spring3 - hibernate3 - mysql5.x 3个配置文件: web.xml struts.xml application.xml文件基本配合
<bean id="anotherFooService" class="x.y.service.ddl.DefaultDdlManager" /> *" read-only="true" /> *" /> *" propagation="NEVER" /> --> <bean id="dataSource" class="org...
3、 配置struts.xml结果页面 <result name="findInStoreTaskSUCCESS">/WEB-INF/pages/zhongzhuan/instore_list.jsp <result name="findOutStoreTaskSUCCESS">/WEB-INF/pages/zhongzhuan/outstore_list.jsp ...
18、两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对? 9 19、是否可以继承String 类? 9 20、以下二条语句返回值为true 的有: 10 21、当一个对象被当作参数传递到一个方法后,此方法可...
18、两个对象值相同(x.equals(y) == true),但却可有不同的hash code,这句话对不对? 9 19、是否可以继承String 类? 9 20、以下二条语句返回值为true 的有: 10 21、当一个对象被当作参数传递到一个方法后,此方法可...