SSH2项目搭建

之前说了一下我所写的这个SSH2 OA项目所用的框架与工具.今天就来总结一下从搭建SSH2开发环境的过程到即将发布的机构管理这个小模块开发的实现思路.
我所做这个项目的目的是来巩固复习Hibernate 和Spring这两个框架(Struts2一只在用).其基本思路和架构也都想好了,也打算利用晚上下班的时间来做出来.想法赶不上计划啊!这段时间有一些其他的事情,再者感觉身体不是怎么好,情绪也受到影响,可能之后就抽出空去搞了.这里就把前几天所写的来公布于众.供大家学习.由于我也是刚刚参加工作,也没什么开发经验.代码写的有不足的地方请大家提出宝贵的意见与见解.
1.首先是搭建环境
虽然我是的是MyEclipse来开发,但我没有借助MyEclipse来帮助我,我全部是手动的方式来构建SSH2环境的.其三个框架所依赖的jar没有一个多余的,做到jar依赖的最小化.
[img]http://dl.iteye.com/upload/attachment/429924/8c742a77-c74f-368c-b39b-d3ea44ae16cc.png[/img]
整个项目架构是:

[img]http://dl.iteye.com/upload/attachment/429926/0e3dc69d-afba-3090-96fc-c5aaeb911bc7.png[/img]
下面是application.xml中的(applicationcontext-common.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: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/aop http://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">

<!-- 配置sessionFactory -->

<bean id="sessionFactory" class="org.springframework.orm.hibernate3.LocalSessionFactoryBean">
<property name="configLocation">
<value>classpath:hibernate.cfg.xml</value>
</property>
</bean>

<!-- 配置事务管理器 -->
<!-- 配置事务管理器bean,使用HibernateTransactionManager事务管理器 -->
<bean id="transactionManager" class="org.springframework.orm.hibernate3.HibernateTransactionManager">
<property name="sessionFactory">
<ref bean="sessionFactory"/>
</property>
</bean>

<!-- 配置事务的传播特性 -->
<!-- 配置事务特性,配置add,delete,update开始的方法,事务传播特性为required -->
<tx:advice id="txAdvice" transaction-manager="transactionManager">
<tx:attributes>
<tx:method name="add*" propagation="REQUIRED"/>
<tx:method name="delete*" propagation="REQUIRED"/>
<tx:method name="modify*" propagation="REQUIRED"/>
<tx:method name="*" read-only="true"/>
</tx:attributes>
</tx:advice>

<!-- 那些类的哪些方法参与事务 -->
<!--
<aop:config>
<aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>
</aop:config>
-->
<!-- 配置那些类的方法进行事务管理,当前com.oa.manager包中的子包, 类中所有方法需要,还需要参考tx:advice的设置 -->
<aop:config>
<aop:pointcut id="allManageMethod" expression="execution(* com.oa.manager.*.*(..))" />
<aop:advisor pointcut-ref="allManageMethod" advice-ref="txAdvice"/>
</aop:config>

<!-- 那些类的哪些方法参与事务 -->
<!--
<aop:config>
<aop:advisor pointcut="execution(* com.oa.manager.*.*(..))" advice-ref="txAdvice"/>
</aop:config>
-->
</beans>

2.机构管理的功能实现:
[img]http://dl.iteye.com/upload/attachment/429928/cb7c7ebf-b3a8-3f95-8854-aed9cafcec2b.png[/img]
[img]http://dl.iteye.com/upload/attachment/429930/eab5812a-6fce-31f5-a67b-3676234d2ff4.png[/img]
代码我打包上传了,效果实现过程可以看我所写的代码.(不知道怎么搞的,它不让我上传了!!!)
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值