s2sh整合之xml方式

说明:本文档所採用的框架版本号为:Struts 2.1.8, Sping2.5.5,  Hibernate 3.5.6

1.    须要的jar包:

------------Strut2-----------:

commons-fileupload-1.2.1.jar

commons-io-1.3.2.jar

commons-logging.jar

freemarker-2.3.15.jar

ognl-2.7.3.jar

struts2-core-2.1.8.1.jar

struts2-spring-plugin-2.1.8.1.jar

xwork-core-2.1.6.jar

-------------Spring---------------:

aspectjrt.jar

aspectjweaver.jar

cglib-nodep-2.1_3.jar

common-annotations.jar

commons-lang.jar

commons-logging.jar

spring.jar

-----------Hibernate------------:

antlr-2.7.6.jar

commons-collections-3.1.jar

dom4j-1.6.1.jar

hibernate-annotations.jar

hibernate-commons-annotations.jar

hibernate3.jar

javassist-3.9.0.GA.jar

jta-1.1.jar

slf4j-api-1.5.8.jar

slf4j-log4j12.jar

------------other-----------------

c3p0-0.9.1.2.jar

json-lib-2.1.jar

jstl.jar

junit.jar

log4j-1.2.15.jar

mysql-connector-java-5.1.10-bin.jar

standard.jar

2.    web.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<web-appxmlns: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_2_5.xsd"version="2.5">

 <!-- spring config begin -->

 <context-param>

   <param-name>contextConfigLocation</param-name>

   <param-value>classpath:spring/applicationContext.xml</param-value>

 </context-param>

 <listener>

   <listener-class>org.springframework.web.context.ContextLoaderListener</listener-class>

 </listener>

 <!-- spring config end-->

 <filter>

   <filter-name>Spring character encoding filter</filter-name>

   <filter-class>org.springframework.web.filter.CharacterEncodingFilter</filter-class>

   <init-param>

   <param-name>encoding</param-name>

   <param-value>UTF-8</param-value>

   </init-param>

 </filter>

 <filter-mapping>

   <filter-name>Spring character encoding filter</filter-name>

   <url-pattern>/*</url-pattern>

 </filter-mapping>

 

 <filter>

   <filter-name>OpenSessionInViewFilter</filter-name>

   <filter-class>org.springframework.orm.hibernate3.support.OpenSessionInViewFilter</filter-class>

 </filter>

 <filter-mapping>

   <filter-name>OpenSessionInViewFilter</filter-name>

   <url-pattern>*.action</url-pattern>

 </filter-mapping>

 <!-- struts config begin-->

 <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>

 <!-- struts config end-->

 <welcome-file-list>

   <welcome-file>login.jsp</welcome-file>

 </welcome-file-list>

</web-app>

3.    applicationContext.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<beansxmlns="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-2.5.xsd

          http://www.springframework.org/schema/context

          http://www.springframework.org/schema/context/spring-context-2.5.xsd

          http://www.springframework.org/schema/aop http://www.springframework.org/schema/aop/spring-aop-2.5.xsd

          http://www.springframework.org/schema/txhttp://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

  

   <import resource="applicationContext-db.xml"/>

   <!-- dao service 默认使用单例 -->

   <beanid="userDao"class="cn.s2sh.demo.dao.impl.UserDaoImpl">

      <propertyname="sessionFactory"ref="sessionFactory"></property>

   </bean>

   <beanid="userService"class="cn.s2sh.demo.service.impl.UserServiceImpl">

      <propertyname="userDao"ref="userDao"/>

   </bean>

   <!-- action 不能使用单例,设置scope="prototype"  -->

   <beanid="userAction"class="cn.s2sh.demo.struts2.action.UserAction"scope="prototype">

      <propertyname="userService"ref="userService"></property>

   </bean>

</beans>

4.    applicationContext-db.xml

<?xmlversion="1.0"encoding="UTF-8"?

>

<beansxmlns="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-2.5.xsd

          http://www.springframework.org/schema/context

           http://www.springframework.org/schema/context/spring-context-2.5.xsd

          http://www.springframework.org/schema/aophttp://www.springframework.org/schema/aop/spring-aop-2.5.xsd

          http://www.springframework.org/schema/tx http://www.springframework.org/schema/tx/spring-tx-2.5.xsd">

   <beanid="sessionFactory"class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">

      <propertyname="configLocation">

          <value>classpath:hibernate/hibernate.cfg.xml</value>

      </property>

   </bean>

   <beanid="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">

      <propertyname="sessionFactory">

          <refbean="sessionFactory"/>

      </property>

   </bean>

   <tx:advicetransaction-manager="transactionManager"id="tx">

      <tx:attributes>

          <tx:methodname="save*"read-only="false"/>

          <tx:methodname="delete*"read-only="false"/>

          <tx:methodname="update*"read-only="false"/>

          <tx:methodname="*"read-only="true"/>

      </tx:attributes>

   </tx:advice>

   <aop:config>

      <aop:pointcutexpression="execution(*cn.s2sh.demo.service.impl.*.*(..))"id="perform"/>

      <aop:advisoradvice-ref="tx"pointcut-ref="perform"/>

   </aop:config>

</beans>

5.    hibernate.cfg.xml

<?

xmlversion='1.0'encoding='UTF-8'?>

<!DOCTYPEhibernate-configuration
PUBLIC

          "-//Hibernate/Hibernate Configuration DTD 3.0//EN"

          "http://hibernate.sourceforge.net/hibernate-configuration-3.0.dtd">

 

<!-- Generated by MyEclipse HibernateTools.                   -->

<hibernate-configuration>

 

<session-factory>

   <propertyname="dialect">

      org.hibernate.dialect.MySQLDialect

   </property>

   <propertyname="connection.url">jdbc:mysql://localhost:3306/s2shdemo</property>

   <propertyname="connection.username">root</property>

   <propertyname="connection.password">root</property>

   <propertyname="connection.driver_class">

      com.mysql.jdbc.Driver

   </property>

   <propertyname="myeclipse.connection.profile">MySQL</property>

   <propertyname="hbm2ddl.auto">update</property>

   <propertyname="show_sql">true</property>

  

   <mappingresource="cn/s2sh/demo/domain/User.hbm.xml"/>

 

</session-factory>

</hibernate-configuration>

6.    struts.xml

<?xmlversion="1.0"encoding="UTF-8"?>

<!DOCTYPEstruts
PUBLIC

   "-//Apache Software Foundation//DTD StrutsConfiguration 2.1.7//EN"

   "http://struts.apache.org/dtds/struts-2.1.7.dtd">

<struts>

   <!-- 开发模式下使用,这样能够打印出更具体的错误信息 ,默认值为false
-->

   <constantname="struts.devMode"value="true"/>

   <!-- 设置浏览器是否缓存静态内容,默认值为true(生产环境下使用),开发阶段最好关闭
-->

   <constantname="struts.serve.static.browserCache"value="false"/>

   <!-- 默认的视图主题 simple模式降低多余代码的生成 -->

   <constantname="struts.ui.theme"value="simple"/>

   <!-- 指定Web应用的默认编码集,相当于调用setCharacterEncoding方法
-->

   <constantname="struts.i18n.encoding"value="UTF-8"/>

   <constantname="struts.custom.i18n.resources"

        value="cn.s2sh.action.token"></constant>

   <!-- 把struts的请求托付给spring管理,

           作用:创建Action实例的过程由spring处理,其它的还是由struts2自己处理
-->

  <constantname="struts.objectFactory"value="spring"/>

  

  <packagename="user"namespace="/"extends="struts-default">

      <actionname="userAction_*"class="userAction"method="{1}">

         <resultname="login">login.jsp</result>

         <resultname="index">index.jsp</result>

         <resultname="listAction">WEB-INF/jsp/user/list.jsp</result>

         <resultname="action2action"type="redirectAction">userAction_getAllUser</result>

         <resultname="addUI">WEB-INF/jsp/user/saveUI.jsp</result>

         <resultname="updateUI">WEB-INF/jsp/user/updateUI.jsp</result>

      </action>

  </package>

</struts>

 

下载完整demo:
http://download.csdn.net/detail/rchm8519/7513457

s2sh框架整合具体配置-xml方式的更多相关文章

  1. ssm三大框架整合基本配置

    ssm三大框架整合基本配置 maven目录结构 数据库脚本mysql create database maven; use maven ; -- --------------------------- ...

  2. Spring + Spring MVC+Hibernate框架整合详细配置

    来源于:http://www.jianshu.com/p/8e2f92d0838c 具体配置参数: Spring: spring-framework-4.2.2Hibernate: hibernate ...

  3. SSM Spring SpringMVC Mybatis框架整合Java配置完整版

    以前用着SSH都是老师给配好的,自己直接改就可以.但是公司主流还是SSM,就自己研究了一下Java版本的配置.网上大多是基于xnl的配置,但是越往后越新的项目都开始基于JavaConfig配置了,这也 ...

  4. Spring+mybatis+struts框架整合的配置具体解释

    学了非常久的spring+mybatis+struts.一直都是单个的用他们,或者是两两组合用过,今天总算整合到一起了,配置起来有点麻烦.可是配置完一次之后.就轻松多了,那么框架整合配置具体解释例如以 ...

  5. S2SH框架整合(注解)Struts2+Spring+Hibernate+MySql

    整合简介 Struts2+Spring4+hibernate4整合,Maven管理jar包,Eclipse工具.注解方式 架构截图   1.Spring整合Hibernate 1.1.创建Hibern ...

  6. SSM框架整合的最新打开方式(打造最详细的SSM整合教程)

    SSM整合 文章已托管到GitHub,大家可以去GitHub查看阅读,欢迎老板们前来Star!搜索关注微信公众号 [码出Offer] 领取各种学习资料! SSM 一.创建一个Maven项目 File ...

  7. springboot使用之二:整合mybatis(xml方式)并添加PageHelper插件

    整合mybatis实在前面项目的基础上进行的,前面项目具体整合请参照springboot使用之一. 一.整合mybatis 整合mybatis的时候可以从mybatis官网下载mybatis官网整合的 ...

  8. spring框架之AspectJ的XML方式完成AOP的开发

    1. 步骤一:创建JavaWEB项目,引入具体的开发的jar包 * 先引入Spring框架开发的基本开发包 * 再引入Spring框架的AOP的开发包 * spring的传统AOP的开发的包 * sp ...

  9. quartz---定时器(配置注解方式&配置xml方式)

    本入门案例基于spring和quartz整合完成. 第一步:创建maven工程,导入spring和quartz相关依赖 第二步:创建任务类 第三步:在spring配置文件中配置任务类 第四步:在spr ...

随机推荐

  1. javascript无缝滚动原理

    相比之下,无缝拼接能避免切换时出现空白,使用户体验更好! 无缝滚动原理: 制作一个双胞胎,内容跟主体内容一致,样式一致,如果横向排列则并排,当切换的时候,就可以弥补主体空白的地方,其他按普通循环操作即 ...

  2. OpenCV学习(9) 分水岭算法(3)

    本教程我学习一下opencv中分水岭算法的具体实现方式. 原始图像和Mark图像,它们的大小都是32*32,分水岭算法的结果是得到两个连通域的轮廓图. 原始图像:(原始图像必须是3通道图像) Mark ...

  3. PostgreSQL源码分析之shared buffer与磁盘文件

    我们知道,PostgreSQL数据库中的信息,最终是要写入持久设备的.那么PostgreSQL是怎么将信息组织存储在磁盘上的呢? Bruce Momjian有一个slide <Insider P ...

  4. jquery点击click事件和blur事件冲突如何解决

    最近做了一个查询小功能,input输入框输入文字后,自动列出几条查询结果,可以键盘上下键或鼠标进行查询结果选择,并且点击输入框其他地方要隐藏这个列出的结果. 但比较头疼的是input上添加blur事件 ...

  5. 详解Vuex常见问题、深入理解Vuex

    Vuex 是一个专为 Vue.js 应用程序开发的状态管理模式.它采用集中式存储管理应用的所有组件的状态,并以相应的规则保证状态以一种可预测的方式发生变化. 状态?我把它理解为在data中的属性需要共 ...

  6. Trie树统计单词前缀

    输入 输入的第一行为一个正整数n.表示词典的大小,其后n行,每一行一个单词(不保证是英文单词,也有可能是火星文单词哦).单词由不超过10个的小写英文字母组成,可能存在同样的单词.此时应将其视作不同的单 ...

  7. Xamarin C# Android for Windows 安装

    Xamarin C# Android for Windows  安装 Xamarin的. Android手动安装 安装Xamarin的  Android在Windows机器上   大多数时候,Xama ...

  8. (剑指Offer)面试题47:不用加减乘除做加法

    题目: 写一个函数,求两个整数之和,要求在函数体内不得使用+.-.*./四则运算符号. 思路: 很容易想到通过位运算来解决问题. 以5+17=22为例,参考十进制加法:1.只做各位相加不进位运算,即得 ...

  9. phpnow 在win7下遇到“安装服务[apache_pn]失败”问题的一种解决办法

    安装PHPnow时如果遇到下列问题: 安装服务[apache_pn]失败.可能原因如下: 1. 服务名已存在,请卸载或使用不同的服务名. 2. 非管理员权限,不能操作 Windows NT 服务. 将 ...

  10. python命令行參数解析实例

    闲言少述,直接上代码 #!/usr/bin/env python # # import json import getopt, sys def usage():     print sys.argv[ ...