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"> <!-- 配置spring的OpenSessionInView模式 【目的:JSp页面访问懒加载数据】 -->
<!-- 注意:访问struts时候需要带上*.action后缀 -->
<filter>
<filter-name>OpenSessionInView</filter-name>
<filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>
</filter>
<filter-mapping>
<filter-name>OpenSessionInView</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping> <!--初始化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> <!--初始化Spring容器--> <!-- 2. spring 配置 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>/WEB-INF/classes/bean-*</param-value>
</context-param>
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener> </web-app>

bean-base.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"
xsi:schemaLocation="http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans.xsd http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx.xsd http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop.xsd http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context.xsd"> <!-- 1) 连接池实例 -->
<bean id="dataSource" class="com.mchange.v2.c3p0.ComboPooledDataSource">
<property name="driverClass" value="com.mysql.jdbc.Driver"></property>
<property name="jdbcUrl" value="jdbc:mysql:///zhongfucheng?characterEncoding=utf8"></property>
<property name="user" value="root"></property>
<property name="password" value="root"></property>
<property name="initialPoolSize" value="3"></property>
<property name="maxPoolSize" value="6"></property>
</bean> <!-- 2) SessionFactory实例创建 -->
<!-- 所有的配置都由spring维护(项目中不需要hibernate.cfg.xml啦) -->
<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<!-- a. 连接池 -->
<property name="dataSource" ref="dataSource"></property> <!-- b. hibernate常用配置: 方言、显示sql、自动建表等 -->
<property name="hibernateProperties">
<props>
<prop key="hibernate.dialect">org.hibernate.dialect.MySQLDialect</prop>
<prop key="hibernate.show_sql">true</prop>
<prop key="hibernate.hbm2ddl.auto">update</prop>
</props>
</property> <!-- c. 映射配置 -->
<property name="mappingLocations">
<list>
<value>classpath:zhongfucheng/entity/*.hbm.xml</value>
</list>
</property>
</bean> <!-- 3) 事务配置 -->
<!-- # 事务管理器 -->
<bean id="txManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory" ref="sessionFactory"></property>
</bean> <!-- # 事务增强 -->
<!-- <tx:advice id="txAdvice" transaction-manager="txManager">
<tx:attributes>
<tx:method name="*" read-only="false"/>
</tx:attributes>
</tx:advice>
&lt;!&ndash; # AOP配置 &ndash;&gt;
<aop:config>
<aop:pointcut expression="execution(* cn.itcast.service.*.*(..))" id="pt"/>
<aop:advisor advice-ref="txAdvice" pointcut-ref="pt"/>
</aop:config>--> <!--4)开启注解扫描器-->
<context:component-scan base-package="zhongfucheng"/> <!--5)开启注解处理事务-->
<tx:annotation-driven transaction-manager="txManager"/> </beans>

Struts2.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> <package name="aaa" extends="struts-default">
<action name="ccc" class="userAction" method="execute">
<result name="success">/show.jsp</result>
</action>
</package>
</struts>

映射文件


<?xml version="1.0" encoding="UTF-8" ?>
<!DOCTYPE hibernate-mapping PUBLIC
"-//Hibernate/Hibernate Mapping DTD 3.0//EN"
"http://www.hibernate.org/dtd/hibernate-mapping-3.0.dtd"> <hibernate-mapping package="zhongfucheng.entity"> <class name="Dept" table="t_dept">
<id name="id" >
<generator class="native"></generator>
</id>
<property name="name" column="name"></property>
</class> </hibernate-mapping>

复用代码【SSH配置文件】的更多相关文章

  1. ssh 配置文件讲解大全 ssh调试模式 sftp scp strace进行调试 特权分离

    ssh 配置文件讲解大全  ssh调试模式  sftp scp strace进行调试  特权分离 http://blog.chinaunix.net/uid-16728139-id-3265394.h ...

  2. Asp.net使用代码修改配置文件的节点值

    使用代码修改配置文件的方法: 1.打开配置文件写入的权限 2.先按节点名称长到要修改的节点,然后删除,紧接着将有新值的节点添加回去 3.关闭配置文件写入的权限 修改Appsetting节点的值,修改其 ...

  3. SSH配置文件和SSM配置文件的写法

    一.SSH配置文件的写法(XML版本) <util:properties id="jdbc" location="classpath:db.properties&q ...

  4. 在Eclipse中制作SSH配置文件提示插件

    原文地址:http://blog.csdn.net/longyuhome/article/details/8968093 这篇博客算是对原先的“在Eclipse中制作和使用struts2配置文件提示插 ...

  5. 由于SSH配置文件的不匹配,导致的Permission denied (publickey)及其解决方法。

    读者如要转载,请标明出处和作者名,谢谢.地址01:http://space.itpub.net/25851087地址02:http://www.cnblogs.com/zjrodger/作者名:zjr ...

  6. AngularJS之使用服务封装可复用代码

    创建服务组件 在AngularJS中创建一个服务组件很简单,只需要定义一个具有$get方法的构造函数, 然后使用模块的provider方法进行登记: //定义构造函数 var myServicePro ...

  7. 001.SSH配置文件

    一 ssh配置文件路径 1.1 ssh客户端配置文件: 路径:/etc/ssh/ssh_config 1.2 ssh服务端配置文件: 路径:/etc/ssh/sshd_config 二 服务器端常用配 ...

  8. 使用IDEA复用代码时常见问题

    使用IDEA复用代码时常见问题 觉得有用的话,欢迎一起讨论相互学习~Follow Me 作为新手在直接复用别人的java代码并使用IDEA进行二次开发时,经常出现一些奇怪的问题,在此做一些总结~ In ...

  9. WCF学习之三, 寄宿方式 代码,配置文件

    可以通过代码或者配置文件寄宿WCF服务,在使用过程中的一些心得,记录一下,方便后续查阅. 预备知识,几个地址的作用 1. behavior.HttpGetUrl  定义元数据的地址,如果不定义基地址, ...

  10. [原]实例-简单设计&精简代码&复用代码

    引言 本文以实际项目为例谈一谈我个人对于软件开发的理解,偏细节   软件项目B 基于.net平台,使用WPF框架,c#语言,MVVM模式开发的桌面软件 该软件支持可视化的设计器功能,允许所见即所得的方 ...

随机推荐

  1. Android手机客户端测试点(全)

    网上看到一个整理比较完善的手机客户端测试:

  2. SpringMVC中文件的上传(上传到服务器)和下载问题(一)

    一.今天我们所说的是基于SpringMVC的关于文件的上传和下载的问题的解决.(这里所说的上传和下载都是上传到服务器与从服务器上下载文件).这里的文件包括我们常用的各种文件.如:文本文件(.txt), ...

  3. 【JSP 标签】选择判断c:choose

    在JSP页面中对 根据一个属性的多个可能的值进行相应的输出 <%@ page language="java" contentType="text/html; cha ...

  4. 区别jquery对象和dom对象及转换方法

    一.jquery对象 由$() 获取,例如 var div = $("#id"); 这个div是jquery对象,它里面没有dom对象自带的方法.常见的dom对象自带的方法, 例如 ...

  5. Redis使用记录-相关资料汇总

    1 redis在centos上的安装 http://www.cnblogs.com/hanyinglong/p/5036558.html 2 redis在windows上的可视化GUI工具 https ...

  6. sort与qsort的用法,建议使用sort

    做ACM题的时候,排序是一种经常要用到的操作.如果每次都自己写个冒泡之类的O(n^2)排序,不但程序容易超时,而且浪费宝贵的比赛时间,还很有可能写错.STL里面有个sort函数,可以直接对数组排序,复 ...

  7. Centos7.2部署.Net Core2.0 WebApi

    部署前准备 1.VisualStudio2017+.netcore2.0SDK 2.Centos7.2 3.SecureCRT,Xftp(根据自己喜好) 创建WebApi项目 修改Program.cs ...

  8. python基础教程(十)

    魔法方法.属性 ------------------------ 准备工作 为了确保类是新型类,应该把 _metaclass_=type 入到你的模块的最开始. class NewType(Objec ...

  9. Tornado模板

    --------------------静态文件-------------------- 1.static_path:通过向web.Application类的构造函数传递一个名为static_path ...

  10. 2017最新的Python教程分享

    Python在数据科学盛行的今天,其易于阅读和编写的特点,越来越受编程者追捧.在IEEE发布的2017年编程语言排行榜中,Python也高居首位.如果你有学Python的计划,快来看看小编分享的Pyt ...