http://www.cnblogs.com/huangkaiyan10/p/4640548.html

项目背景

前一段时间,开始做一个项目,在考虑数据访问层是考虑技术选型,考虑过原始的ADO.NET、微软的EF、NH等。再跟经理讨论后,经理强调不要用 Ef,NH做ORM,后期的sql优化不好做,公司也没有人对EF,Nh 等orm优化比较熟悉的。强调说的,我们的项目要做的得简单,可以使用ADO.NET 写原始的sql。但我自己还是喜欢ORM的,它可以提高数据访问层的开发。有一天,在订阅张善友 doNet跨平台微信公众号里,看到Dapper的推荐。了解之后,我自己喜欢喜欢Dapper,可以满足我这个项目的经理的要求,同时Dapper 对数据库的访问能做到Ado.net一样快。

下面的链接是Dapper 在github的地址  https://github.com/StackExchange/dapper-dot-net。

使用 Dapper 进行简单增删改查示例

   1、首先根据数据库表定义实体对象, 这个工作完全可以使用T4、Nvelocity或者RazorEngine 写一个代码生成器根据数据库表对象自动生成数据库表实体对象。这里我自己根据表写了一个对象

  1. [Table("UserRole")]
  2. public class UserRoleDbEntity:DbEntityModelBase
  3. {
  4. [Description("用户编号,来自用户表")]
  5. public int UserId
  6. {
  7. get;
  8. set;
  9. }
  10.  
  11. [Description("角色编号,来自于角色表")]
  12. public int RoleId
  13. {
  14. get;
  15. set;
  16. }
  17. /// <summary>
  18. /// 备注:AuthorityEnum.AuthorityValue 的取值范围是根据 AuthorityEnum位运算 或 与 的结果集;不可随意赋值
  19. /// </summary>
  20. [Description("权限值")]
  21. public int AuthorityValue { get; set; }
  22.  
  23. /// <summary>
  24. /// 根据 AuthorityEnum 枚举值生成的描述
  25. /// </summary>
  26. [Description("权限描述")]
  27. public string AuthorityDescription { get; set; }
  28. }
  29.  
  30. /// <summary>
  31. /// 所有DbEntityModel项目中的实体必须继承DbEntityModelBase或其子类,使用supperType模式控制共有子类的行为或者状态,此项目中的类根据数据库基本表或者视图保持基本一致
  32. /// </summary>
  33. public abstract class DbEntityModelBase
  34. {
  35. [Description("Guid标识")]
  36. public string GuidMark
  37. {
  38. get;
  39. set;
  40. }
  41. [Description("自增Id列")]
  42. public int Id
  43. {
  44. get;
  45. set;
  46. }
  47. [Description("排序,倒序")]
  48. public int Sort
  49. {
  50. get;
  51. set;
  52. }
  53. }

2. 在DAL层就可以使用实体对象传参 或者作为返回值

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using OnlineExercise.DbAccess;
  6. using Dapper;
  7. using System.Configuration;
  8. using System.Data;
  9. using MySql.Data;
  10. using MySql.Data.MySqlClient;
  11. using OnlineExercise.DbEntityModel;
  12. using OnlineExercise.Log;
  13. using OnlineExercise.Infrastructrue;
  14.  
  15. namespace OnlineExercise.DbAccess.SysAdminModule
  16. {
  17. public class UserRoleDB:DalBase<UserRoleDB>
  18. {
  19. public int AddUserRole(UserRoleDbEntity model)
  20. {
  21. int affecgtRow = 0;
  22. string sql = @"INSERT INTO `userrole`
  23. (`GuidMark`,
  24. `UserId`,
  25. `RoleId`,
  26. `AuthorityValue`,
  27. `AuthorityDescription`)
  28. VALUES (@GuidMark,
  29. @UserId,
  30. @RoleId,
  31. @AuthorityValue,
  32. @AuthorityDescription);";
  33. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  34. {
  35. affecgtRow = conn.Execute(sql, model);
  36. }
  37. return affecgtRow;
  38. }
  39.  
  40. public int UpdateUserRoleByRoleIdAndUserId(UserRoleDbEntity model)
  41. {
  42. int affecgtRow = 0;
  43. string sql = @"UPDATE `userrole`
  44. SET `AuthorityValue` = @AuthorityValue,
  45. `AuthorityDescription` = @AuthorityDescription
  46. WHERE `UserId` = @UserId
  47. AND `RoleId` = @RoleId;";
  48. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  49. {
  50. affecgtRow = conn.Execute(sql, model);
  51. }
  52. return affecgtRow;
  53. }
  54.  
  55. public int UpdateUserRoleByRoleId(UserRoleDbEntity model)
  56. {
  57. int affecgtRow = 0;
  58. string sql = @"UPDATE `userrole`
  59. SET `AuthorityValue` = @AuthorityValue,
  60. `AuthorityDescription` = @AuthorityDescription
  61. WHERE `RoleId` = @RoleId;";
  62. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  63. {
  64. affecgtRow = conn.Execute(sql, model);
  65. }
  66. return affecgtRow;
  67. }
  68.  
  69. public int UpdateUserRoleByUserId(UserRoleDbEntity model)
  70. {
  71. int affecgtRow = 0;
  72. string sql = @"UPDATE `userrole`
  73. SET `AuthorityValue` = @AuthorityValue,
  74. `AuthorityDescription` = @AuthorityDescription
  75. WHERE `UserId` = @UserId;";
  76. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  77. {
  78. affecgtRow = conn.Execute(sql, model);
  79. }
  80. return affecgtRow;
  81. }
  82.  
  83. public List<UserRoleDbEntity> GetUserRoleListByRoleId(UserRoleDbEntity model)
  84. {
  85. List<UserRoleDbEntity> modelList = null;
  86. string sql = @"SELECT
  87. `Id`,
  88. `GuidMark`,
  89. `sort`,
  90. `UserId`,
  91. `RoleId`,
  92. `AuthorityValue`,
  93. `AuthorityDescription`
  94. FROM `userrole`
  95. WHERE RoleId=@RoleId;";
  96. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  97. {
  98. modelList = conn.Query<UserRoleDbEntity>(sql, model).ToList<UserRoleDbEntity>();
  99. }
  100. return modelList;
  101. }
  102.  
  103. public List<UserRoleDbEntity> GetUserRoleListByUserId(string userId)
  104. {
  105. List<UserRoleDbEntity> modelList = null;
  106. string sql = @"SELECT
  107. `Id`,
  108. `GuidMark`,
  109. `sort`,
  110. `UserId`,
  111. `RoleId`,
  112. `AuthorityValue`,
  113. `AuthorityDescription`
  114. FROM `userrole`
  115. WHERE UserId=@UserId;";
  116. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  117. {
  118. modelList = conn.Query<UserRoleDbEntity>(sql, new { UserId =userId}).ToList<UserRoleDbEntity>();
  119. }
  120. return modelList;
  121. }
  122.  
  123. public List<UserRoleDbEntity> GetUserRoleListByRoleIdAndUserId(UserRoleDbEntity model)
  124. {
  125. List<UserRoleDbEntity> modelList = null;
  126. string sql = @"SELECT
  127. `Id`,
  128. `GuidMark`,
  129. `sort`,
  130. `UserId`,
  131. `RoleId`,
  132. `AuthorityValue`,
  133. `AuthorityDescription`
  134. FROM `userrole`
  135. WHERE RoleId=@RoleId and UserId=@UserId;";
  136. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  137. {
  138. modelList = conn.Query<UserRoleDbEntity>(sql, model).ToList<UserRoleDbEntity>();
  139. }
  140. return modelList;
  141. }
  142.  
  143. public int DeleteUserRoleByUserId(string userId)
  144. {
  145. int affecgtRow = 0;
  146. string sql = @"DELETE
  147. FROM `userrole`
  148. WHERE `UserId` = @UserId";
  149. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  150. {
  151. affecgtRow = conn.Execute(sql, new { UserId = userId });
  152. }
  153. return affecgtRow;
  154. }
  155.  
  156. public int DeleteUserRoleByRoleId(string roleId)
  157. {
  158. int affecgtRow = 0;
  159. string sql = @"DELETE
  160. FROM `userrole`
  161. WHERE `RoleId` = @RoleId;";
  162. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  163. {
  164. affecgtRow = conn.Execute(sql, new { RoleId = roleId });
  165.  
  166. }
  167. return affecgtRow;
  168. }
  169.  
  170. public DataTable GetRoleInfoByUserId(string userId)
  171. {
  172. DataTable dt = null;
  173.  
  174. string sql = @"SELECT b.*,a.userid,c.name as userName FROM userrole AS a
  175. INNER JOIN role AS b ON a.roleid=b.id
  176. INNER JOIN USER AS c ON c.id=a.userid
  177. WHERE a.userid=@userid;";
  178. using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
  179. {
  180. IDataReader reader = conn.ExecuteReader(sql, new { userid=userId });
  181. dt = CoreUtil.DataReader2Table(reader);
  182. reader.Dispose();
  183. }
  184.  
  185. return dt;
  186. }
  187.  
  188. }
  189. }

Dapper的优势

1、Dapper是一个轻型的ORM类

2、 Dapper语法简单,如果你喜欢写原始的sql,你一定喜欢Dapper。同时团队人员也很容易上手

3、Dapper 速度快,速度接近ADO.NET访问数据库的效率。

4、多数据库切换方便

public int UpdateUserRoleByRoleId(UserRoleDbEntity model)
        {
            int affecgtRow = 0;
            string sql = @"UPDATE  `userrole`
                            SET  `AuthorityValue` = @AuthorityValue,
                                `AuthorityDescription` = @AuthorityDescription
                            WHERE `RoleId` = @RoleId;";
            using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
            {
                affecgtRow = conn.Execute(sql, model);
            }
            return affecgtRow;
        }

这里mysql如果要切换为Sql Server ,只要修改链接  MySqlConnection---》SqlConnection。

Dapper更多特性

1、支持动态dynamic绑定

  1. var rows = connection.Query("select 1 A, 2 B union all select 3, 4");
  2.  
  3. ((int)rows[].A)
  4. .IsEqualTo();
  5.  
  6. ((int)rows[].B)
  7. .IsEqualTo();
  8.  
  9. ((int)rows[].A)
  10. .IsEqualTo();
  11.  
  12. ((int)rows[].B)
  13. .IsEqualTo();
  1. 2、支持批量插入
  1. connection.Execute(@"insert MyTable(colA, colB) values (@a, @b)",
  2. new[] { new { a=, b= }, new { a=, b= }, new { a=, b= } }
  3. ).IsEqualTo(); // 3 rows inserted: "1,1", "2,2" and "3,3"
  1. 3、支持多表关联
  1. var sql =
  2. @"select * from #Posts p
  3. left join #Users u on u.Id = p.OwnerId
  4. Order by p.Id";
  5.  
  6. var data = connection.Query<Post, User, Post>(sql, (post, user) => { post.Owner = user; return post;});
  7. var post = data.First();
  8.  
  9. post.Content.IsEqualTo("Sams Post1");
  10. post.Id.IsEqualTo();
  11. post.Owner.Name.IsEqualTo("Sam");
  12. post.Owner.Id.IsEqualTo();
  1.  
  1. 4、支持多结果查询
  1. var sql =
  2. @"
  3. select * from Customers where CustomerId = @id
  4. select * from Orders where CustomerId = @id
  5. select * from Returns where CustomerId = @id";
  6.  
  7. using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
  8. {
  9. var customer = multi.Read<Customer>().Single();
  10. var orders = multi.Read<Order>().ToList();
  11. var returns = multi.Read<Return>().ToList();
  12. ...
  13. }
  1. 5 支持存储过程
  1. var user = cnn.Query<User>("spGetUser", new {Id = },
  2. commandType: CommandType.StoredProcedure).SingleOrDefault();
  3. // 你还可以获取存储过程out参数的输出值或者返回值
  4. var p = new DynamicParameters();
  5. p.Add("@a", );
  6. p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
  7. p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
  8.  
  9. cnn.Execute("spMagicProc", p, commandType: CommandType.StoredProcedure);
  10.  
  11. int b = p.Get<int>("@b");
  12. int c = p.Get<int>("@c");
  1. 6、参数自动绑定
  1. new {A = 1, B = "b"} // A will be mapped to the param @A, B to the param @B

看到Dapper那么特性,觉得使用Dapper非常方便,使用也非常方便,扩展性也非常高。 当我用Dapper写一个demo给项目经理看的时候,项目经理就同意使用
Dapper 作为ORM 进行数据访问层的开发。从此就爱上了Dapper。
希望这篇文章给你带来对Dapper清晰的了解。

  1.  
  1.  

项目背景

前一段时间,开始做一个项目,在考虑数据访问层是考虑技术选型,考虑过原始的ADO.NET、微软的EF、NH等。再跟经理讨论后,经理强调不要用 Ef,NH做ORM,后期的sql优化不好做,公司也没有人对EF,Nh 等orm优化比较熟悉的。强调说的,我们的项目要做的得简单,可以使用ADO.NET 写原始的sql。但我自己还是喜欢ORM的,它可以提高数据访问层的开发。有一天,在订阅张善友 doNet跨平台微信公众号里,看到Dapper的推荐。了解之后,我自己喜欢喜欢Dapper,可以满足我这个项目的经理的要求,同时Dapper 对数据库的访问能做到Ado.net一样快。

下面的链接是Dapper 在github的地址  https://github.com/StackExchange/dapper-dot-net。

使用 Dapper 进行简单增删改查示例

   1、首先根据数据库表定义实体对象, 这个工作完全可以使用T4、Nvelocity或者RazorEngine 写一个代码生成器根据数据库表对象自动生成数据库表实体对象。这里我自己根据表写了一个对象

  1. [Table("UserRole")]
  2. public class UserRoleDbEntity:DbEntityModelBase
  3. {
  4. [Description("用户编号,来自用户表")]
  5. public int UserId
  6. {
  7. get;
  8. set;
  9. }
  10.  
  11. [Description("角色编号,来自于角色表")]
  12. public int RoleId
  13. {
  14. get;
  15. set;
  16. }
  17. /// <summary>
  18. /// 备注:AuthorityEnum.AuthorityValue 的取值范围是根据 AuthorityEnum位运算 或 与 的结果集;不可随意赋值
  19. /// </summary>
  20. [Description("权限值")]
  21. public int AuthorityValue { get; set; }
  22.  
  23. /// <summary>
  24. /// 根据 AuthorityEnum 枚举值生成的描述
  25. /// </summary>
  26. [Description("权限描述")]
  27. public string AuthorityDescription { get; set; }
  28. }
  29.  
  30. /// <summary>
  31. /// 所有DbEntityModel项目中的实体必须继承DbEntityModelBase或其子类,使用supperType模式控制共有子类的行为或者状态,此项目中的类根据数据库基本表或者视图保持基本一致
  32. /// </summary>
  33. public abstract class DbEntityModelBase
  34. {
  35. [Description("Guid标识")]
  36. public string GuidMark
  37. {
  38. get;
  39. set;
  40. }
  41. [Description("自增Id列")]
  42. public int Id
  43. {
  44. get;
  45. set;
  46. }
  47. [Description("排序,倒序")]
  48. public int Sort
  49. {
  50. get;
  51. set;
  52. }
  53. }

2. 在DAL层就可以使用实体对象传参 或者作为返回值

  Dapper的优势

1、Dapper是一个轻型的ORM类

2、 Dapper语法简单,如果你喜欢写原始的sql,你一定喜欢Dapper。同时团队人员也很容易上手

3、Dapper 速度快,速度接近ADO.NET访问数据库的效率。

4、多数据库切换方便

public int UpdateUserRoleByRoleId(UserRoleDbEntity model)
        {
            int affecgtRow = 0;
            string sql = @"UPDATE  `userrole`
                            SET  `AuthorityValue` = @AuthorityValue,
                                `AuthorityDescription` = @AuthorityDescription
                            WHERE `RoleId` = @RoleId;";
            using (IDbConnection conn = new MySqlConnection(GlobalVariablesManager.G_Strconn))
            {
                affecgtRow = conn.Execute(sql, model);
            }
            return affecgtRow;
        }

这里mysql如果要切换为Sql Server ,只要修改链接  MySqlConnection---》SqlConnection。

Dapper更多特性

1、支持动态dynamic绑定

  1. var rows = connection.Query("select 1 A, 2 B union all select 3, 4");
  2.  
  3. ((int)rows[].A)
  4. .IsEqualTo();
  5.  
  6. ((int)rows[].B)
  7. .IsEqualTo();
  8.  
  9. ((int)rows[].A)
  10. .IsEqualTo();
  11.  
  12. ((int)rows[].B)
  13. .IsEqualTo();
  1. 2、支持批量插入
  1. connection.Execute(@"insert MyTable(colA, colB) values (@a, @b)",
  2. new[] { new { a=, b= }, new { a=, b= }, new { a=, b= } }
  3. ).IsEqualTo(); // 3 rows inserted: "1,1", "2,2" and "3,3"
  1. 3、支持多表关联
  1. var sql =
  2. @"select * from #Posts p
  3. left join #Users u on u.Id = p.OwnerId
  4. Order by p.Id";
  5.  
  6. var data = connection.Query<Post, User, Post>(sql, (post, user) => { post.Owner = user; return post;});
  7. var post = data.First();
  8.  
  9. post.Content.IsEqualTo("Sams Post1");
  10. post.Id.IsEqualTo();
  11. post.Owner.Name.IsEqualTo("Sam");
  12. post.Owner.Id.IsEqualTo();
  1. 4、支持多结果查询
  1. var sql =
  2. @"
  3. select * from Customers where CustomerId = @id
  4. select * from Orders where CustomerId = @id
  5. select * from Returns where CustomerId = @id";
  6.  
  7. using (var multi = connection.QueryMultiple(sql, new {id=selectedId}))
  8. {
  9. var customer = multi.Read<Customer>().Single();
  10. var orders = multi.Read<Order>().ToList();
  11. var returns = multi.Read<Return>().ToList();
  12. ...
  13. }
  1. 5 支持存储过程
  1. var user = cnn.Query<User>("spGetUser", new {Id = },
  2. commandType: CommandType.StoredProcedure).SingleOrDefault();
  3. // 你还可以获取存储过程out参数的输出值或者返回值
  4. var p = new DynamicParameters();
  5. p.Add("@a", );
  6. p.Add("@b", dbType: DbType.Int32, direction: ParameterDirection.Output);
  7. p.Add("@c", dbType: DbType.Int32, direction: ParameterDirection.ReturnValue);
  8.  
  9. cnn.Execute("spMagicProc", p, commandType: CommandType.StoredProcedure);
  10.  
  11. int b = p.Get<int>("@b");
  12. int c = p.Get<int>("@c");
  1. 6、参数自动绑定
  1. new {A = , B = "b"} // A will be mapped to the param @A, B to the param @B
  1. 看到Dapper那么特性,觉得使用Dapper非常方便,使用也非常方便,扩展性也非常高。 当我用Dapper写一个demo给项目经理看的时候,项目经理就同意使用
    Dapper 作为ORM 进行数据访问层的开发。从此就爱上了Dapper
    希望这篇文章给你带来对Dapper清晰的了解。同时如果这文章给你到来了帮助,也别忘了帮忙推荐。

Dapper进行增删改查 z的更多相关文章

  1. 使用轻量级ORM Dapper进行增删改查

      项目背景 前一段时间,开始做一个项目,在考虑数据访问层是考虑技术选型,考虑过原始的ADO.NET.微软的EF.NH等.再跟经理讨论后,经理强调不要用Ef,NH做ORM,后期的sql优化不好做,公司 ...

  2. Dapper.Contrib——更加优雅地使用Dapper进行增删改查

    简介 Dapper是介于Entity framework与ADO的折中选择.既满足手写查询的高性能需求,又简化了数据库对象映射为内存对象的繁杂工作.Dapper.Contrib是对Dapper的进一步 ...

  3. Dapper基本增删改查

    说明: 1.在using语句块中不用dbConnection.Open(),因为Execute方法中会Open,并且在执行完成会Close. 2.在Ado.Net中要手动Open,在Using语句块中 ...

  4. .net Core+Dapper MySQL增删改查

    新建一个用户表,以该有为例 1.Model层 public class TuiUsers { public int id { get; set; } public string userName { ...

  5. Dapper逆天入门~强类型,动态类型,多映射,多返回值,增删改查+存储过程+事物案例演示

    Dapper的牛逼就不扯蛋了,答应群友做个入门Demo的,现有园友需要,那么公开分享一下: 完整Demo:http://pan.baidu.com/s/1i3TcEzj 注 意 事 项:http:// ...

  6. 在C#的控制台应用中使用Dapper链接MySQL并执行一些增删改查

    一.首先先创建一个C#的控制台应用 二.然后添加上必要的命名空间 using System;using System.Collections.Generic;using MySql.Data.MySq ...

  7. tp框架的增删改查

    首先,我们来看一下tp框架里面的查询方法: 查询有很多种,代码如下: <?php namespace Admin\Controller; use Think\Controller; class ...

  8. nodejs+easyui(抽奖活动后台)增删改查

    aaarticlea/png;base64,iVBORw0KGgoAAAANSUhEUgAAAfAAAAJACAIAAAD97KNZAAAgAElEQVR4nO2daXxb5Z2o7w+dO1/ufL ...

  9. 使用EF自带的EntityState枚举和自定义枚举实现单个和多个实体的增删改查

    本文目录 使用EntityState枚举实现单个实体的增/删/改 增加:DbSet.Add = > EntityState.Added 标记实体为未改变:EntityState.Unchange ...

随机推荐

  1. VUE安装步骤1

    文件结构 用官方的 vue-cli 生成的项目文件结构如上图所示,简单介绍下上面图中各文件的作用. src 文件夹 : 1. assets 文件夹:存放各种资源文件,如图片等 2. component ...

  2. NestJS 用TypeScript开发 nodeJS后端

    NestJS A progressive Node.js framework for building efficient and scalable server-side applications ...

  3. 《C++ Primer(第五版)》知识巩固

    运行平台:ubuntu 12.04/GCC 4.8.0 第二章:基本内置类型 1.decltype类型指示符 当我们从表达式的类型来推断要定义的类型时,可以使用decltype()来解析:declty ...

  4. Oracle 多行、多列子查询

    本文使用到的是oracle数据库scott方案所带的表,scott是oracle数据库自带的方案,使用前请确保其解锁 一.多行子查询 多行子查询子查询是嵌入在其他Sql语句中的select语句,Ora ...

  5. 《C++ Primer》〓〓〓〓〓〓〓〓〓〓【第七章】

    7.5.1 构造函数初始化列表 如果成员是const.引用,或者属于某种未提供默认构造函数的类类型,我们必须通过构造函数初始值列表为这些成员提供初值. 成员的初始化顺序与他们在类定义中的出现顺序一致. ...

  6. MVVM 事件转命令1

    EventToCommand 在WPF中,并不是所有控件都有Command,例如TextBox,那么当文本改变,我们需要处理一些逻辑,这些逻辑在ViewModel 中,没有Command如何绑定呢?这 ...

  7. Java - 如何进行安全发布

    首先让我简单解释一下所谓"发布". 发布(publish),使对象可以在当前作用域之外的代码中可见,如果该对象被发布,则该对象的非私有域中引用的所有实例同样也会被发布. 不仅仅是作 ...

  8. OC与JS交互之JavaScriptCore

    JavaScriptCore提供了JavaScript和Objective-C桥接的Obj-C API.JavaScriptCore提供了让我们脱离UIWebView执行JavaScript脚本的能力 ...

  9. shell变量类型和运算符

    一.shell变量的应用 1.shell变量的种类 ①用户自定义变量:由用户自己定义,修改和使用 ②预定义变量:bash预定义的特殊变量,不能直接修改 ③位置变量:通过命令行给程序传递执行参数 二.变 ...

  10. springMVC介绍及配置

    Spring MVC的Controller用于处理用户的请求.Controller相当于Struts 1里的Action,他们的实现机制.运行原理都类似. Controller是个接口,一般直接继承A ...