开发基础框架:mybatis-3.2.8 +hibernate4.0+spring3.0+struts2.3
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>
|
转载于:https://www.cnblogs.com/telwanggs/p/5403249.html
开发基础框架:mybatis-3.2.8 +hibernate4.0+spring3.0+struts2.3相关推荐
- Qt程序开发通用框架
基于Qt5.6.3通用的程序开发基础框架. 此框架采用流行的分层+插件架构 技术架构采用"3/N层+插件架构"(目前非常流行的架构),其中"3/N层"对系统进行 ...
- VIVE开发基础(A、快速入门篇)(Yanlz+HTC+VIVE+VR+AR+MR+XR+SteamVR+CameraRig+LightHouse+HeadSet+Teleport+立钻哥哥+)
<HTC_VIVE开发基础> 版本 作者 参与者 完成日期 备注 HTC_VIVE_V01_1.0 严立钻 2018.08.23 <HTC_VIVE开发基础>发布说明: +++ ...
- SSM框架开发-基础案例
SSM框架整合基础案例详解 1.数据库环境 创建一个存放书籍数据的数据库表 CREATE DATABASE `ssmbuild`;USE `ssmbuild`;DROP TABLE IF EXISTS ...
- java微信接口开发java SpringMVC mybatis 后台框架
获取[下载地址] QQ: 313596790 [免费支持更新] 支持三大数据库 mysql oracle sqlsever 更专业.更强悍.适合不同用户群体 [ 新录针对本系统的视频教 ...
- Xamarin图表开发基础教程(13)OxyPlot框架支持的其它图表
Xamarin图表开发基础教程(13)OxyPlot框架支持的其它图表 除了以上提到的图表外,OxyPlot组件还包含了6种类型的其它图表,分别为等高线图.箱线图.饼图.热图.散点图和散点误差图,如图 ...
- Xamarin图表开发基础教程(12)OxyPlot框架支持的金融图表类型
Xamarin图表开发基础教程(12)OxyPlot框架支持的金融图表类型 OxyPlot组件中支持5种类型的金融图表,它们分别为销量图.高低图.股票K线图.股票走势图和旧式股票图,如图1.20~1. ...
- Xamarin图表开发基础教程(11)OxyPlot框架支持的图表类型
Xamarin图表开发基础教程(11)OxyPlot框架支持的图表类型 OxyPlot组件中支持7种类型的条型图表,分别为普通条形图.线型条形图.矩形条形图.差值图.龙卷风图.普通柱形图和柱形误差图, ...
- Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型
Xamarin图表开发基础教程(10)OxyPlot框架支持的图表类型 OxyPlot组件支持26种图表,这些图表按照功能和样式可以分为4大类,分别为线型图表.条型图表.金融图表和其它图表. 线型图表 ...
- Xamarin图表开发基础教程(8)OxyPlot框架
Xamarin图表开发基础教程(8)OxyPlot框架 [示例OxyPlotFormsDemo]在Xamarin.Forms中实现线图的显示. (1)打开Xamarin.Forms项目. (2)将Ox ...
最新文章
- pytorch 中 logsoftmax 与 softmax的区别
- Windows Phone 8 开发资源汇总
- vue ajax跨域提交,vue-cli开发时ajax跨域的方法
- 作者:石勇(1956-),男,中国科学院大学经济管理学院教授、博士生导师,发展中国家科学院院士...
- JavaScript 内存机制(前端同学进阶必备)
- DLL初步和钩子入门
- 雷云3计算机不满足系统要求,电工进网作业许可考试(高压类)4、5、6章题库(无答案)...
- Idea突然不停indexing的问题
- uniapp唤醒手机地图app
- cad快速选择命令快捷键_CAD快捷键命令:倒角的使用技巧
- 精选汇总 | 开心一刻
- networkx画图
- 渗透学什么?渗透测试中超全的提权思路来了!
- 数据结构(c语言版 第二版 严蔚敏)第一张绪论笔记
- #python对数列的进行排列
- linux ssh复制粘贴,Linux下SSH Session复制功能实现方法
- 使用openssl转换pem为pfx证书
- python实现c语言编译器安卓版_c语言编译器ide下载app-c语言编译器ide软件下载v1.5.1 安卓版-2265安卓网...
- Spring之AOP系列--指示器
- 2014小米,百度,pptv,去哪儿笔试题目回忆
热门文章
- cad2016中选择全图字体怎么操作_抖音上的书单都是用啥做的,抖音书单图片怎么做...
- arduino uno 掌控板实现数据上传到阿里云平台
- 使用linux_使用 AppImage 进行 Linux 软件包管理 | Linux 中国
- python中config命令_python的logging.config使用详解
- 【STM32】手把手固件库开发工程建立
- Linux并发与竞争
- STM32学习——GPIO的操作
- s3c6410存储器映射
- golang字节数组拷贝BlockCopy函数实现
- Luogu P2733 家的范围 Home on the Range