一:项目下载地址(点击 Source code(zip))

https://github.com/fzxblgong/frame_2014-12-15/releases

版本:v1.2
大小:20M

二:ssm(mybatis-3.2.8 +hibernate4.0+spring3.0+struts2.3) version v1.3 功能

新增:
+8.框架在支持mybatis-3.2.8基础上又整合进hibernate4,并支持注释。
+9.使用注释ssh方式实现JqueryMiniUi多选树。实例路径:/organization/organization_tree.jsp

1.action,service,dao,支持spring业务类注释方式依赖注入。 
2.mybatis支持接口注释开发,支持sql mapper的xml配置开发。 
3.集成log4j配置输出文件。 
4.集成常用异步上传ajaxFileupload测试实例。 测试路径:/ajaxfileupload/ajaxupload.jsp
5.集成上传进度百分比进度测试实例。(ajax异步sessionkey计算)
6.集成JqueryMiniUi前端框架。
7.集成用户列表展示功能。(包括分页查询,分页排序,条件查询,按列排序)测试路径:/user/userlist.jsp

三:运行环境

1.JDK "1.6.0_10-rc2";
2.MyEclipse6.5;
3.Tomcat6.0;
4.MySql5.0;
5.Windows7 32bit.

注:
1.因为jqueryminiui分Eclipse和Myeclipse版本,我集成的是Meclipse版本,虽然我没试过eclipse是否正常,但为了测试稳定最好用Myeclipse试下。
2.另外项目下有两个Junit4.0版本的测试类,测试类路径为/src/com/mybatistest,需要引入相关的Junit4.0支持库,谢谢。

 
 

代码片段(11)[全屏查看所有代码]

1. [图片] src目录结构.jpg

2. [图片] 用户管理列表.jpg

3. [图片] ajaxfileupload异步上传及进度.jpg

4. [图片] organization树.jpg

5. [代码]bean.xml spring配置文件

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
<?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.2.xsd
         http://www.springframework.org/schema/context
         http://www.springframework.org/schema/context/spring-context-3.2.xsd
         http://www.springframework.org/schema/aop
         http://www.springframework.org/schema/aop/spring-aop-3.2.xsd
         http://www.springframework.org/schema/tx
         http://www.springframework.org/schema/tx/spring-tx-3.2.xsd">
 
    <context:annotation-config />
    <!-- 组件的扫描包路径,如@Service,@Repository注释的类,才能被spring找到,而spring只有找到这样的单例才能将其注入给需要的其他类使用 -->
    <context:component-scan base-package="com" />
    <!--
    <context:property-placeholder location="classpath:config/jdbc.properties"/>
     -->
    <bean id="dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        <property name="driverClassName" value="com.mysql.jdbc.Driver" />
        <property name="url"
            value="jdbc:mysql://127.0.0.1:3306/mybatis" />
        <property name="username" value="root" />
        <property name="password" value="admin" />
    </bean>
    <bean id="sqlSessionFactory"
        class="org.mybatis.spring.SqlSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <property name="configLocation"
            value="classpath:mybatis-config.xml"/>
        <property name="typeAliasesPackage" value="com.mybatis.model"/>
    </bean>
    <!-- 注解方式(原生)
     
    <bean id="userMapper"
        class="org.mybatis.spring.mapper.MapperFactoryBean">
        <property name="mapperInterface"
            value="com.mybatis.dao.UserMapper" />
        <property name="sqlSessionFactory" ref="sqlSessionFactory" />
    </bean>
    <bean id="userService" class="com.mybatis.service.UserService">
        <property name="userMapper" ref="userMapper" />
    </bean>-->
     
    <!-- 事物管理 -->
    <bean id="transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource" />
    </bean>
    <!-- MapperScannerConfigurer来帮我们自动扫描和注册Mapper接口,使用逗号或者分号进行分隔 参考:http://haohaoxuexi.iteye.com/blog/1843309-->
    <bean class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        <property name="basePackage" value="com.mybatis.dao"/>
        <!-- MapperScannerConfigurer将只注册继承自markerInterface的接口:http://haohaoxuexi.iteye.com/blog/1843309-->
        <!--
        <property name="markerInterface" value="com.mybatis.dao.UserMapper"/>
         --> 
        <property name="sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    </bean>
    <!-- 在Dao中直接使用SqlSessionTemplate来编程 -->
    <bean id="sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
       <constructor-arg index="0" ref="sqlSessionFactory" />
    </bean>
     
      <!-- hibernate配置 -->
    <bean id="sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        <property name="dataSource" ref="dataSource" />
        <!-- 此配置为扫描com包下的n级model包下的实体,根据具体项目修改 -->
        <property name="packagesToScan" value="com.**.model" />
        <property name="hibernateProperties">
            <props>
                <!-- Oracle的方言
                <prop key="hibernate.dialect">org.hibernate.dialect.OracleDialect</prop>
                 -->
                <!-- Mysql的方言 -->
                <prop key="hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                </prop>
                <prop key="hibernate.show_sql">true</prop>
                <prop key="hibernate.format_sql">true</prop>
                <prop key="hibernate.hbm2ddl.auto">update</prop>
            </props>
        </property>
    </bean>
    <!-- <bean id="txManager" class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        <property name="dataSource" ref="dataSource"/> </bean> -->
    <bean id="txManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        <property name="sessionFactory">
            <ref local="sessionFactory" />
        </property>
    </bean>
    <tx:annotation-driven transaction-manager="txManager" />
</beans>

6. [代码]1.支持注释 UserDaoImpl.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
package com.mybatis.basedao;
 
import org.mybatis.spring.SqlSessionTemplate;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Repository;
 
import com.mybatis.model.User;
@Repository
public class UserDaoImpl {
    @Autowired
    private SqlSessionTemplate sqlSessionTemplate;
    public User getUserById(){
        User user = sqlSessionTemplate.selectOne("com.mybatis.dao.UserMapper.selectUserById", 1);
        return user;
    }
}

7. [代码]2.mybatis支持接口注释方式

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
package com.mybatis.dao;
 
import com.mybatis.model.User;
 
public interface UserMapper {
     
    public User selectUserById(Integer id2);
    public void insertUser(User user);
    /**
     * 注释方式也可使用:
     * 百度:MyBatis-Spring-1.2.2 指导手册
     * @param userId
     * @return
     */
    /*@Select("SELECT * FROM users WHERE id = #{userId}")
    User getUser(@Param("userId") String userId);*/
}

8. [代码]3.log4j日志集成

1
2
3
4
5
log4j.appender.R=org.apache.log4j.RollingFileAppender
log4j.appender.R.File=D\:\\Test_Log4j.log
log4j.appender.R.MaxFileSize=100KB log4j.appender.R.MaxBackupIndex=1
log4j.appender.R.layout=org.apache.log4j.PatternLayout
log4j.appender.R.layout.ConversionPattern=%-d{yyyy-MM-dd HH\:mm\:ss} %p %t %c - %m%n

9. [代码]4.ajaxFileUpload ajaxupload.jsp

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
<img id="loading" src="${pageContext.request.contextPath}/ajaxfileupload/loading.gif" style="display:none;">
    <form name="form" action="" method="POST" enctype="multipart/form-data">
    <input id="fileToUpload" type="file" size="45" name="fileToUpload" class="input"/>
    <button class="button" id="buttonUpload" onclick="return ajaxFileUpload();">Upload</button>
    <div id ="percent" style="border:1px solid blue;width:200px;height:15px;" >
        <div id="percontent">
        </div>
    </div>
function ajaxFileUpload()
{
//执行异步上传...
}
function getPer(){
//获得百分比例进度
}

10. [代码]OrganizationAction.java

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
package com.myssh.action;
 
import java.beans.IntrospectionException;
import java.io.IOException;
import java.lang.reflect.InvocationTargetException;
import java.util.ArrayList;
import java.util.List;
import java.util.Map;
 
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Component;
 
import com.myssh.model.Organization;
import com.myssh.service.OrganizationService;
import com.ssh.baseaction.BaseAction;
import com.util.BeanToMapUtil;
@Component
public class OrganizationAction extends BaseAction{
    @Autowired
    private OrganizationService organizationService;
    @Override
    public Object getModel() {
        // TODO Auto-generated method stub
        return null;
    }
 
    @Override
    public void prepare() throws Exception {
        // TODO Auto-generated method stub
         
    }
    public String toOrganizationTree(){
        return "to_organization_tree";
    }
    public void getTreeDataList() throws IOException, IntrospectionException, IllegalAccessException, InvocationTargetException{
        List<Organization> organizationList = this.organizationService.getOrgTree();
        List<Map> orgMapList = new ArrayList<Map>();
        for(Organization org : organizationList){
            Map orgMap = BeanToMapUtil.convertBean(org);
            orgMapList.add(orgMap);
            System.out.println(orgMap);
        }
        String json = com.util.JSON.Encode(organizationList);
        System.out.println(json);
        this.setAjax(json);
    }
}

11. [代码]organization_tree.jsp JqueryMiniUi的tree实现实例

1
2
3
4
5
6
<ul id="tree2" class="mini-tree" url="${pageContext.request.contextPath}/organization/getTreeDataList.do" style="width:300px;height:250px;padding:5px;"
       showTreeIcon="true" textField="name" idField="id" parentField="p_id" resultAsTree="false" 
       allowSelect="false" enableHotTrack="false" expandOnLoad="true"
       showCheckBox="true" checkRecursive="false" autoCheckParent="true"
       >
   </ul>

开发基础框架:mybatis-3.2.8 +hibernate4.0+spring3.0+struts2.3的更多相关文章

  1. 基于SpringBoot的Web API快速开发基础框架

    其实还是很因为懒,才会有这个案例项目的产生,每次开启一个终端的小服务都要整理一次框架,造成重复的.不必要的.缺乏创造性的劳动,SO,本着可以用.用着简单的原则上传代码到Github,希望有需要的朋友直 ...

  2. IOS开发 基础框架(Fondation Framework)的线程安全

    有一种误解,认为基础框架(Foundation framework)是线程安全的,而Application Kit是非线程安全的.不幸的是,这是一个总的概括,从而造成一点误导.每个框架都包含了线程安全 ...

  3. 第一个基础框架 — mybatis框架 — 更新完毕

    1.Mybatis是什么? 百度百科一手 提取一下重点: MyBatis 本是apache的一个开源项目iBatis.即:mybatis的原名为:ibatis 2010年迁移到google code, ...

  4. iOS开发基础框架

    ---恢复内容开始--- //appdelegate ////  AppDelegate.m//  iOS开发架构////  Copyright © 2016年 Chason. All rights ...

  5. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建四:配置springmvc

    在用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试的基础上 继续进行springmvc的配置 一:配置完善web.xml文件

  6. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建三:配置spring并测试

    这一部分的主要目的是 配置spring-service.xml  也就是配置spring  并测试service层 是否配置成功 用IntelliJ IDEA 开发Spring+SpringMVC+M ...

  7. 用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建二:配置MyBatis 并测试(1 构建目录环境和依赖)

    引言:在用IntelliJ IDEA 开发Spring+SpringMVC+Mybatis框架 分步搭建一   的基础上 继续进行项目搭建 该部分的主要目的是测通MyBatis 及Spring-dao ...

  8. mybatis学习笔记之基础框架(2)

    mybatis学习笔记之基础框架(2) mybatis是一个持久层的框架,是apache下的顶级项目. mybatis让程序将主要精力放在sql上,通过mybatis提供的映射方式,自由灵活生成满足s ...

  9. Mybatis基础:Mybatis映射配置文件,Mybatis核心配置文件,Mybatis传统方式开发

    一.Mybatis快速入门 1.1 框架介绍 框架是一款半成品软件,我们可以基于这个半成品软件继续开发,来完成我们个性化的需求! 框架:大工具,我们利用工具,可以快速开发项目 (mybatis也是一个 ...

随机推荐

  1. Java性能优化权威指南-读书笔记(二)-JVM性能调优-概述

    概述:JVM性能调优没有一个非常固定的设置,比如堆大小设置多少,老年代设置多少.而是要根据实际的应用程序的系统需求,实际的活跃内存等确定.正文: JVM调优工作流程 整个调优过程是不断重复的一个迭代, ...

  2. [Android UI] Shape详解 (GradientDrawable)

    转载自:http://blog.csdn.net/feng88724/article/details/6398193 在Android开发过程中,经常需要改变控件的默认样式, 那么通常会使用多个图片来 ...

  3. ubuntu 图形界面查看隐藏文件

    在 Linux 下以 . 开头的文件或文件夹为隐藏文件,在图形界面(nautilus)下可用 CTRL + H 显示隐藏文件,终端下者可以用 ls -a 显示所有文件.

  4. 一、HTML和CSS基础--网页布局--如何用css进行网页布局

    什么叫做布局? 又称版式布局,是网页UI设计师将有限的视觉元素进行有机的排列组合. 网页设计的特点 网页可以自适应宽度 网页的高度理论上可以无限延长 网页分栏 分栏又称为分列,常见的布局分为:一列布局 ...

  5. zabbix (一:zabbix服务端)

    默认情况下zabbix有5个进程: zabbix_agent  zabbix_get zabbix_proxy zabbix_sender zabbix_server,另外一个zabbix_java_ ...

  6. ASP.NET MVC那些事

    MVC的由来: 在MVC模式之前,View界面的呈现.用户交互操作的捕捉与相应.业务流程的执行以及数据的存储等都是在一起的,这种设计模式叫自治视图. 这重设计模式主要存在三大弊端: 重用性:业务逻辑与 ...

  7. 创建一个ASP.NET MVC OutputCache ActionFilterAttribute

    在每一个web应用程序中, 有的情况下,你想在一段时间内缓存一个具体的页面HTML输出,因为相关的数据和处理并不是总是变化.这种缓存的响应是储存在服务器的内存中.因为没有必要的额外处理,它提供了非常快 ...

  8. linux下安装pymssql

    WIN下安装PYMSSQL,由于我没有系统管理权限,无法安装, 那只好在LINUX下面安装罗.. 以下这个文章帮助我搞定. http://blog.csdn.net/five3/article/det ...

  9. SharedPreferences存储

    *通过getSharedPreferences()方法获得SharedPreferences对象 SharedPreferences pref = getShaedPreferences(“key”, ...

  10. [转]notepad++各种插件

    http://www.crifan.com/files/doc/docbook/rec_soft_npp/release/htmls/npp_common_plugins.html