标签:
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> |
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
|
<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(){ //获得百分比例进度 } |
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); } } |
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
标签:
原文地址:http://www.cnblogs.com/love540376/p/5403249.html