热门标签 | HotTags
当前位置:  开发笔记 > 编程语言 > 正文

开发基础框架:mybatis3.2.8+hibernate4.0+spring3.0+struts2.3

一:项目下载地址(点击 Source code(zip))https:github.comfzxblgongframe_2014-12-15releases版本:v1.2大小:20
一:项目下载地址(点击 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支持库,谢谢。

 
标签: Struts Spring MyBatis Hibernate ajax File Upload
 

代码片段(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
"1.0" encoding="UTF-8"?>
"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">
 
    
    
    package="com" />
    
    "dataSource"
        class="org.apache.commons.dbcp.BasicDataSource"
        destroy-method="close">
        "driverClassName" value="com.mysql.jdbc.Driver" />
        "url"
            value="jdbc:mysql://127.0.0.1:3306/mybatis" />
        "username" value="root" />
        "password" value="admin" />
    
    "sqlSessionFactory"
        class="org.mybatis.spring.SqlSessionFactoryBean">
        "dataSource" ref="dataSource" />
        "configLocation"
            value="classpath:mybatis-config.xml"/>
        "typeAliasesPackage" value="com.mybatis.model"/>
    
    
     
    
    "transactionManager"
        class="org.springframework.jdbc.datasource.DataSourceTransactionManager">
        "dataSource" ref="dataSource" />
    
    
    class="org.mybatis.spring.mapper.MapperScannerConfigurer">
        "basePackage" value="com.mybatis.dao"/>
        
         
        "sqlSessionFactoryBeanName" value="sqlSessionFactory"/>
    
    
    "sqlSession" class="org.mybatis.spring.SqlSessionTemplate">
       "0" ref="sqlSessionFactory" />
    
     
      
    "sessionFactory"
        class="org.springframework.orm.hibernate4.LocalSessionFactoryBean">
        "dataSource" ref="dataSource" />
        
        "packagesToScan" value="com.**.model" />
        "hibernateProperties">
            
                
                
                "hibernate.dialect">
                    org.hibernate.dialect.MySQLDialect
                
                "hibernate.show_sql">true
                "hibernate.format_sql">true
                "hibernate.hbm2ddl.auto">update
            
        
    
    
    "txManager"
        class="org.springframework.orm.hibernate4.HibernateTransactionManager">
        "sessionFactory">
            "sessionFactory" />
        
    
    "txManager" />

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
"loading" src="${pageContext.request.contextPath}/ajaxfileupload/loading.gif" java string">"display:none;">
    "form" action="" method="POST" enctype="multipart/form-data">
    "fileToUpload" type="file" size="45" name="fileToUpload" class="input"/>
    
    
"percent" java string">"border:1px solid blue;width:200px;height:15px;" >
        
"percontent">
        
    
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 organizatiOnList= this.organizationService.getOrgTree();
        List orgMapList = new ArrayList();
        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
    "tree2" class="mini-tree" url="${pageContext.request.contextPath}/organization/getTreeDataList.do" java string">"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"
       >
   

开发基础框架:mybatis-3.2.8 +hibernate4.0+spring3.0+struts2.3


推荐阅读
  • 本文讨论了Alink回归预测的不完善问题,指出目前主要针对Python做案例,对其他语言支持不足。同时介绍了pom.xml文件的基本结构和使用方法,以及Maven的相关知识。最后,对Alink回归预测的未来发展提出了期待。 ... [详细]
  • 知识图谱——机器大脑中的知识库
    本文介绍了知识图谱在机器大脑中的应用,以及搜索引擎在知识图谱方面的发展。以谷歌知识图谱为例,说明了知识图谱的智能化特点。通过搜索引擎用户可以获取更加智能化的答案,如搜索关键词"Marie Curie",会得到居里夫人的详细信息以及与之相关的历史人物。知识图谱的出现引起了搜索引擎行业的变革,不仅美国的微软必应,中国的百度、搜狗等搜索引擎公司也纷纷推出了自己的知识图谱。 ... [详细]
  • Java验证码——kaptcha的使用配置及样式
    本文介绍了如何使用kaptcha库来实现Java验证码的配置和样式设置,包括pom.xml的依赖配置和web.xml中servlet的配置。 ... [详细]
  • 本文介绍了lua语言中闭包的特性及其在模式匹配、日期处理、编译和模块化等方面的应用。lua中的闭包是严格遵循词法定界的第一类值,函数可以作为变量自由传递,也可以作为参数传递给其他函数。这些特性使得lua语言具有极大的灵活性,为程序开发带来了便利。 ... [详细]
  • 在说Hibernate映射前,我们先来了解下对象关系映射ORM。ORM的实现思想就是将关系数据库中表的数据映射成对象,以对象的形式展现。这样开发人员就可以把对数据库的操作转化为对 ... [详细]
  • 本文介绍了在SpringBoot中集成thymeleaf前端模版的配置步骤,包括在application.properties配置文件中添加thymeleaf的配置信息,引入thymeleaf的jar包,以及创建PageController并添加index方法。 ... [详细]
  • 本文讲述了作者通过点火测试男友的性格和承受能力,以考验婚姻问题。作者故意不安慰男友并再次点火,观察他的反应。这个行为是善意的玩人,旨在了解男友的性格和避免婚姻问题。 ... [详细]
  • 本文详细介绍了Linux中进程控制块PCBtask_struct结构体的结构和作用,包括进程状态、进程号、待处理信号、进程地址空间、调度标志、锁深度、基本时间片、调度策略以及内存管理信息等方面的内容。阅读本文可以更加深入地了解Linux进程管理的原理和机制。 ... [详细]
  • 1,关于死锁的理解死锁,我们可以简单的理解为是两个线程同时使用同一资源,两个线程又得不到相应的资源而造成永无相互等待的情况。 2,模拟死锁背景介绍:我们创建一个朋友 ... [详细]
  • 后台获取视图对应的字符串
    1.帮助类后台获取视图对应的字符串publicclassViewHelper{将View输出为字符串(注:不会执行对应的ac ... [详细]
  • Google Play推出全新的应用内评价API,帮助开发者获取更多优质用户反馈。用户每天在Google Play上发表数百万条评论,这有助于开发者了解用户喜好和改进需求。开发者可以选择在适当的时间请求用户撰写评论,以获得全面而有用的反馈。全新应用内评价功能让用户无需返回应用详情页面即可发表评论,提升用户体验。 ... [详细]
  • 《数据结构》学习笔记3——串匹配算法性能评估
    本文主要讨论串匹配算法的性能评估,包括模式匹配、字符种类数量、算法复杂度等内容。通过借助C++中的头文件和库,可以实现对串的匹配操作。其中蛮力算法的复杂度为O(m*n),通过随机取出长度为m的子串作为模式P,在文本T中进行匹配,统计平均复杂度。对于成功和失败的匹配分别进行测试,分析其平均复杂度。详情请参考相关学习资源。 ... [详细]
  • 本文介绍了通过ABAP开发往外网发邮件的需求,并提供了配置和代码整理的资料。其中包括了配置SAP邮件服务器的步骤和ABAP写发送邮件代码的过程。通过RZ10配置参数和icm/server_port_1的设定,可以实现向Sap User和外部邮件发送邮件的功能。希望对需要的开发人员有帮助。摘要长度:184字。 ... [详细]
  • 动态规划算法的基本步骤及最长递增子序列问题详解
    本文详细介绍了动态规划算法的基本步骤,包括划分阶段、选择状态、决策和状态转移方程,并以最长递增子序列问题为例进行了详细解析。动态规划算法的有效性依赖于问题本身所具有的最优子结构性质和子问题重叠性质。通过将子问题的解保存在一个表中,在以后尽可能多地利用这些子问题的解,从而提高算法的效率。 ... [详细]
  • 高质量SQL书写的30条建议
    本文提供了30条关于优化SQL的建议,包括避免使用select *,使用具体字段,以及使用limit 1等。这些建议是基于实际开发经验总结出来的,旨在帮助读者优化SQL查询。 ... [详细]
author-avatar
long--Journey
这个家伙很懒,什么也没留下!
PHP1.CN | 中国最专业的PHP中文社区 | DevBox开发工具箱 | json解析格式化 |PHP资讯 | PHP教程 | 数据库技术 | 服务器技术 | 前端开发技术 | PHP框架 | 开发工具 | 在线工具
Copyright © 1998 - 2020 PHP1.CN. All Rights Reserved | 京公网安备 11010802041100号 | 京ICP备19059560号-4 | PHP1.CN 第一PHP社区 版权所有