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
|
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">
class = "org.apache.commons.dbcp.BasicDataSource" destroy-method= "close" >
value= "jdbc:mysql://127.0.0.1:3306/mybatis" />
class = "org.mybatis.spring.SqlSessionFactoryBean" >
value= "classpath:mybatis-config.xml" />
class = "org.springframework.jdbc.datasource.DataSourceTransactionManager" >
class = "org.springframework.orm.hibernate4.LocalSessionFactoryBean" >
org.hibernate.dialect.MySQLDialect
class = "org.springframework.orm.hibernate4.HibernateTransactionManager" >
|
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; } } |
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);*/ } |
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 |
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
|
function ajaxFileUpload() { //执行异步上传... } function getPer(){ //获得百分比例进度 } |
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 this .organizationService.getOrgTree(); List 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); } } |
1
2
3
4
5
6
|
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