三大框架的配置整合
来源:互联网 发布:数据来源于天地图 编辑:程序博客网 时间:2024/05/29 19:23
首先是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:context="http://www.springframework.org/schema/context"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-3.0.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-3.0.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-3.0.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-3.0.xsd"><context:annotation-config /><!--注解配置 --><context:component-scan base-package="com.zzw" /><context:property-placeholder location="classpath:jdbc.properties" /><bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource"destroy-method="close"><property name="driverClass" value="${jdbc.driverClassName}" /><property name="jdbcUrl" value="${jdbc.url}" /><property name="user" value="${jdbc.username}" /><property name="password" value="${jdbc.password}" /><!-- 指定连接数据库连接池的初始化连接数 --><property name="initialPoolSize" value="1" /><!-- 指定连接数据库连接池的最大连接数 --><property name="maxPoolSize" value="40" /><!-- 指定连接数据库连接池的最小连接数 --><property name="minPoolSize" value="1" /><!-- 指定连接数据库连接池的连接的最大空闲时间 --><property name="maxIdleTime" value="20" /></bean><bean id="sessionFactory"class="org.springframework.orm.hibernate3.annotation.AnnotationSessionFactoryBean"><property name="dataSource" ref="dataSource" /><property name="packagesToScan"><list><value>com.zzw.entity</value></list></property><property name="hibernateProperties"><props><prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop><prop key="hibernate.hbm2ddl.auto">update</prop><prop key="hibernate.show_sql">true</prop><prop key="javax.persistence.validation.mode">none</prop><prop key="hibernate.format_sql">true</prop></props></property></bean><bean id="hibernateTemplate" class="org.springframework.orm.hibernate3.HibernateTemplate"><property name="sessionFactory" ref="sessionFactory"></property></bean> <bean id="txManager"class="org.springframework.orm.hibernate3.HibernateTransactionManager"><property name="sessionFactory" ref="sessionFactory" /></bean> <!-- 事务控制xml方式 --><aop:config><aop:pointcut id="service"expression="execution(public * com.zzw.service..*.*(..))" /><aop:advisor pointcut-ref="service" advice-ref="txAdvice" /></aop:config><tx:advice id="txAdvice" transaction-manager="txManager"><tx:attributes><tx:method name="get*" read-only="true" /><tx:method name="save*" propagation="REQUIRED" /><tx:method name="add*" propagation="REQUIRED" /><tx:method name="delete*" propagation="REQUIRED" /><tx:method name="update*" propagation="REQUIRED" /></tx:attributes></tx:advice> <!-- 事务控制注解方式 --><tx:annotation-driven transaction-manager="txManager" /> </beans>
接着是web.xml的配置
<?xml version="1.0" encoding="UTF-8"?> <web-app xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://java.sun.com/xml/ns/javaee" xmlns:web="http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd" xsi:schemaLocation="http://java.sun.com/xml/ns/javaee http://java.sun.com/xml/ns/javaee/web-app_3_0.xsd" version="3.0"> <listener> <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class> </listener> <!-- 启动项目是自动加载spring --> <context-param> <param-name>contextConfigLocation</param-name> <param-value>classpath:applicationContext.xml</param-value> </context-param> <!-- struts的核心拦截器 --> <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> <welcome-file-list> <welcome-file>index.jsp</welcome-file> </welcome-file-list> </web-app>
最后是struts.xml的配置
<?xml version="1.0" encoding="UTF-8" ?> <!DOCTYPE struts PUBLIC "-//Apache Software Foundation//DTD Struts Configuration 2.3//EN" "http://struts.apache.org/dtds/struts-2.3.dtd"> <struts> <constant name="struts.enable.DynamicMethodInvocation" value="true" /> <constant name="struts.devMode" value="true" /> <package name="default" namespace="/" extends="struts-default"> <action name="employee" class="com.zzw.action.EmployeeAction"> <result name="loginSuccess">/showAllEmployee.jsp</result> <result name="loginFail">/loginFail.jsp</result> <result name="showAll">/showAllEmployee.jsp</result> <result name="addSuccess">/add_success.jsp</result> <result name="deleteSuccess">/delete_success.jsp</result> <result name="goUpdatePage">/updateEmployee.jsp</result> <result name="updateSuccess">/updateSuccess.jsp</result> </action> </package> </struts>
0 0
- ssh三大框架整合的配置
- 三大框架的配置整合
- 三大框架的整合
- 三大框架的整合
- 基于XML配置的SSH三大框架整合
- 三大框架整合文件配置
- 三大框架整合
- 三大框架整合
- 三大框架整合
- 三大框架的整合实例
- ssh三大框架的整合
- 三大框架的整合和测试
- SSH之三大框架的整合
- 【Spring九】三大框架的整合
- 学习日记:三大框架的整合
- 整合SSM三大框架的思路
- SSM三大框架的整合
- 三大框架的整合原理
- JDBC更新10W级以上数据性能优化
- nginx开机自动启动脚本
- Android下动态链接库.so调用的简单例子
- 【算法导论】有向图的可达矩阵
- 程序员技术练级攻略
- 三大框架的配置整合
- 查看oracle表空间大小
- 创建和绘制渐变
- VC屏幕截图 ,保存成本地文件
- cocos2d-x开发之如何在Android应用中加入广告(转载)
- IO_REMOVE_LOCK(删除锁)
- Eclipse中快捷键组合
- C#在无参构造器中初始化成员变量
- hive reduce 个数