--------------------------------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"
xmlns:p="http://www.springframework.org/schema/p"
xmlns:aop="http://www.springframework.org/schema/aop"
xmlns:context="http://www.springframework.org/schema/context"
xmlns:jee="http://www.springframework.org/schema/jee"
xmlns:tx="http://www.springframework.org/schema/tx"
xsi:schemaLocation="
http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-4.0.xsd
http://www.springframework.org/schema/beans http://www.springframework.org/schema/beans/spring-beans-4.0.xsd
http://www.springframework.org/schema/context http://www.springframework.org/schema/context/spring-context-4.0.xsd
http://www.springframework.org/schema/jee http://www.springframework.org/schema/jee/spring-jee-4.0.xsd
http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-4.0.xsd">

<!-- 定义数据源 -->
<bean id="dataSource" class=".." destroy-method="close">
<property name="driverClassName" value="${jdbc.driverClassName}"/>
<property name="url" value="${jdbc.url}"/>
<property name="username" value="${jdbc.username}"/>
<property name="password" value="${jdbc.password}"/>
</bean>

<!-- Spring2.5中新加入了"context"命名空间,这个命名空间让我们能够得到更为简洁的方式来实现属性占位符 -->
<context:property-placeholder location="classpath:jdbc.properties"/>

<!-- 定义session工厂 -->
<bean id="sessionFactory" class="..">
<property name="dataSource" ref="dataSource" />
<property name="configLocation" value="classpath:hibernate.cfg.xml" />
<!-- 自动扫描注解方式配置的hibernate类文件 -->
<property name="packagesToScan">
<list>
<value>com.java1234.entity</value>
</list>
</property>
</bean>

<!-- 定义事务管理器 -->
<bean id="transactionManager" class="..">
<property name="sessionFactory" ref="sessionFactory" />
</bean>

<!-- 定义事务通知属性 -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<!-- 定义事务传播属性 -->
<tx:attributes>
<tx:method name="*" propagation="REQUIRED" read-only="true" />
</tx:attributes>
</tx:advice>

<!-- 定义事务切面 -->
<aop:config>
<aop:pointcut id="serviceOperation" expression="execution(* com.java1234.service.*.*(..))" />
<aop:advisor advice-ref="txAdvice" pointcut-ref="serviceOperation" />
</aop:config>

<!-- 自动扫描加载构建bean -->
<context:component-scan base-package="com.java1234" />

<!-- 结束 -->
</beans>

--------------------------------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.action.extension" value="action" />

<package name="s2sh" namespace="/user" extends="struts-default">
<action name="user_*" method="{1}" class="com.java1234.action.UserAction">
<result name="success">/success.jsp</result>
<result name="error">/index.jsp</result>
</action>
</package>

<!-- 结束 -->
</struts>

--------------------------------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"
xsi:schemaLocation="http://java.sun.com/xml/ns/javaee
http://java.sun.com/xml/ns/javaee/web-app_2_5.xsd"
id="WebApp_ID" version="2.5">

<!-- 定义了WEB应用的名字 -->
<display-name>S2SH</display-name>
<welcome-file-list>
<welcome-file>index.jsp</welcome-file>
</welcome-file-list>

<!-- 添加对spring的支持 -->
<context-param>
<param-name>contextConfigLocation</param-name>
<param-value>classpath:applicationContext.xml</param-value>
</context-param>

<!-- 定义Spring监听器,加载Spring -->
<listener>
<listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>
</listener>

<!-- 添加对struts2的支持 -->
<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>

<!-- Session延迟加载到页面 -->
<filter>
<filter-name>openSessionInViewFilter</filter-name>
<filter-class>org.springframework.orm.hibernate4.support.OpenSessionInViewFilter</filter-class>
<init-param>
<param-name>singleSession</param-name>
<param-value>true</param-value>
</init-param>
</filter>
<filter-mapping>
<filter-name>openSessionInViewFilter</filter-name>
<url-pattern>*.action</url-pattern>
</filter-mapping>

<!-- 结束 -->
</web-app>

SSH框架配置的更多相关文章

  1. java教程(五)SSH框架-配置

    前言:从这篇博客開始我将继续讲述Java教程:SSH篇.主要内容环绕SSH框架分析与搭建,今天先简介一下SSH的配置. SSH配置顺序是: spring-->hibernate-->str ...

  2. ssh框架配置过程

    1.pom.xml配置依赖 <?xml version="1.0" encoding="UTF-8"?> <project xmlns=&qu ...

  3. SSH框架配置释义

      创建一个bean, 依赖注入支持的不同注入方式及具体配置方法 属性注入 通过setter()方法注入bean的属性或者依赖对象.属性注入要求bean需要提供一个默认构造函数和对应的setter方法 ...

  4. ssh框架配置数据源 数据库连接没有正常释放

    通过多天的改bug 对数据源这个东西了解多了..    我发现 spring+hibernate下  申请数据库连接是在一个action方法内  也就是说  action 里面有三个 service方 ...

  5. ssh框架配置事务管理器

    http://blog.163.com/zsq303288862@126/blog/static/9374596120111182446727/

  6. SSH框架中配置log4j的方法

    SSH框架中使用log4j的方便之处 1. 动态的改变记录级别和策略,即修改log4j.properties,不需要重启Web应用,这需要在web.xml中设置一下.2. 把log文件定在 /WEB- ...

  7. SSH框架结合案例构建配置

    ssh框架概述 SSH是 struts+spring+hibernate的一个集成框架,是目前比较流行的一种Web应用程序开源框架.区别于 Secure Shell . 集成SSH框架的系统从职责上分 ...

  8. SSH框架系列:Spring配置多个数据源

    分类: [java]2013-12-09 16:59 1247人阅读 评论(0) 收藏 举报 1.问题的引入 对于普通的SSH框架而言,一般配置一个数据源,一个SessionFactory,一个事务管 ...

  9. SSH框架整合--applicationContext.xml文件配置实例

    <?xml version="1.0" encoding="UTF-8"?><beans xmlns="http://www.spr ...

随机推荐

  1. LIFO栈 ADT接口 实现十进制转其他进制

    LIFO 接口 Stack.h //LIFO 链栈初始化 void InitStack(Stack top){ //LIFO 链栈判断栈空 boolean StackKEmpty(Stack top) ...

  2. C基础 之 list 库奥义

    前言 - 关于 list 思考 list 是最基础的数据结构也是数据结构的基础. 高级 C 代码纽带也是 list. 扯一点, 当你走进了 C 的殿堂, 那么你和 list 增删改查那就是一辈子丫 ~ ...

  3. MySQL存取特殊数据类型

    一.存取大文本数据 数据库设计: DDL: CREATE TABLE `article` ( `id` ) COLLATE utf8_bin NOT NULL COMMENT '编号', `conte ...

  4. 20155218 2006-2007-2 《Java程序设计》第一周学习总结

    20155218 2006-2007-2 <Java程序设计>第1周学习总结 教材学习内容总结 浏览教材每章提出一个问题 组建如何与容器互动 PATH与classpath的对比 java的 ...

  5. 20155339 《Java程序设计》实验五网络编程与安全实验报告

    20155339 <Java程序设计>实验五网络编程与安全实验报告 实验内容 实验一 1.两人一组结对编程: 参考http://www.cnblogs.com/rocedu/p/67667 ...

  6. BZOJ4034_树上操作_KEY

    题目传送门 这道题可以树链剖分+线段树. 其他操作模板,第二个操作只需要将x~x+size[x]-1区间加值即可. code: #include <cstdio> #include < ...

  7. 【BZOJ4803】逆欧拉函数

    [BZOJ4803]逆欧拉函数 题面 bzoj 题解 题目是给定你\(\varphi(n)\)要求前\(k\)小的\(n\). 设\(n=\prod_{i=1}^k{p_i}^{c_i}\) 则\(\ ...

  8. RegExp,实现匹配合法邮箱(英文邮箱)的正则表达式

    邮箱列表:@qq.com.@vip.qq.com.@foxmail.com,数字邮箱暂时不考虑 以下邮箱列表用于测试: lihaha@qq.com lihaha@vip.qq.com lihaha@f ...

  9. python3工作环境部署+spyder3+jupyter notebook

    1.python3安装 1)官网去下载python3.7版本,双击安装,只要注意勾选写到PATH就行,其它直接NEXT. 2)安装完成,CMD键入 python 回车,跳出python界面就是成功. ...

  10. Elasticsearch6.2集群搭建

    Elasticsearch6.2集群搭建 2018年04月02日 11:07:45 这个名字想了很久 阅读数:14154    版权声明:本博客为学习.笔记之用,以笔记形式记录学习的知识与感悟.学习过 ...