自己动手搭建经典的3层 Asp.Net MVC
1:IBaseDAL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks; namespace C01.ZRF.IDAL
{
public interface IBaseDAL<T> where T : class
{ int SaveChanges(); void Add(T model); void Delete(T model); void DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> delWhere); void Modify(T model, params string[] propertyNames); IQueryable<T> Where(Expression<Func<T, bool>> whereLambda); IQueryable<T> WhereOrder<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true); IQueryable<T> WhereInclude(Expression<Func<T, bool>> whereLambda, params string[] includePropertyNames); IQueryable<T> WhereInclude<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames); IEnumerable<T> WherePaged<TKey>(int PageIndex, int PageSize, out int totalCount, Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames); IQueryable<T> QueryBySql(string sql, params System.Data.SqlClient.SqlParameter[] ps);
}
}
T4模板生成的接口
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
<#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, );
MetadataTools ef = new MetadataTools(this);
string inputFile1 = @"E:\Temp\test01\3LaySolution\C10.ZRF.Model\Model1.edmx";
EdmItemCollection ItemCollection1 = loader.CreateEdmItemCollection(inputFile1);
string namespaceName = code.VsNamespaceSuggestion();
EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C10.ZRF.Model; namespace C01.ZRF.IDAL
{
<#
foreach (EntityType entity in ItemCollection1.GetItems<EntityType>().OrderBy(e => e.Name))
{
#>
public partial interface I<#=entity.Name#>_DAL : IBaseDAL<<#=entity.Name#>>{ }
<#}#>
}
生成后的效果如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C10.ZRF.Model; namespace C01.ZRF.IDAL
{
public partial interface IBuyCar_DAL : IBaseDAL<BuyCar>{ }
public partial interface IMenu_DAL : IBaseDAL<Menu>{ }
public partial interface IProduct_DAL : IBaseDAL<Product>{ }
public partial interface IRole_DAL : IBaseDAL<Role>{ }
public partial interface IroleMenu_DAL : IBaseDAL<roleMenu>{ }
public partial interface IuerRole_DAL : IBaseDAL<uerRole>{ }
public partial interface IUser_DAL : IBaseDAL<User>{ } }
2:DAL
using System;
using System.Collections.Generic;
using System.Data.Entity.Infrastructure;
using System.Linq;
using System.Linq.Expressions; namespace C01.ZRF.DAL
{
using C01.ZRF.IDAL;
using IOC;
using System.Data.Entity; public class BaseDAL<T>:IBaseDAL<T> where T:class
{
//1.创建EF上下文
// BaseDBContext db = new BaseDBContext();
DbContext db = DBContextFactory.GetDbContext(); #region 0.0 批量更新EF容器数据到数据库 +int SaveChanges()
/// <summary>
/// 0.0 批量更新EF容器数据到数据库
/// </summary>
/// <returns>返回受影响行数</returns>
public int SaveChanges()
{
return db.SaveChanges();
}
#endregion #region 1.0 新增方法 +void Add(T model)
/// <summary>
/// 1.0 新增方法
/// </summary>
/// <param name="model"></param>
public void Add(T model)
{
//1.直接通过EF上下文的 Set方法 获取一个 针对于 T类 做操作的 DbSet对象
//var dbSet = db.Set<T>();
//dbSet.Add(model);
db.Set<T>().Add(model);
}
#endregion #region 2.0 删除方法 +void Delete(T model)
/// <summary>
/// 2.0 删除方法
/// </summary>
/// <param name="model"></param>
public void Delete(T model)
{
DbEntityEntry entry = db.Entry<T>(model);
entry.State = System.Data.Entity.EntityState.Deleted;
}
#endregion #region 2.1 条件删除方法 +void DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> delWhere)
/// <summary>
/// 2.1 条件删除方法
/// </summary>
/// <param name="delWhere">要删除的元素查询条件</param>
public void DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> delWhere)
{
var delList = db.Set<T>().Where(delWhere);
foreach (T model in delList)
{
Delete(model);
}
}
#endregion #region 3.0 修改实体 + void Modify(T model, params string[] propertyNames)
/// <summary>
/// 3.0 修改实体
/// </summary>
/// <param name="model"></param>
/// <param name="propertyNames"></param>
public void Modify(T model, params string[] propertyNames)
{
DbEntityEntry entry = db.Entry<T>(model);
entry.State = System.Data.Entity.EntityState.Unchanged;
foreach (string proName in propertyNames)
{
entry.Property(proName).IsModified = true;
}
}
#endregion #region 4.0 查询方法 +IQueryable<T> Where(Expression<Func<T, bool>> whereLambda)
/// <summary>
/// 4.0 查询方法
/// </summary>
/// <param name="whereLambda"></param>
/// <returns></returns>
public IQueryable<T> Where(Expression<Func<T, bool>> whereLambda)
{
return db.Set<T>().Where(whereLambda);
}
#endregion #region 4.1 查询方法 -带排序 +IQueryable<T> WhereOrder<TKey>
/// <summary>
/// 4.1 查询方法 -带排序
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <param name="whereLambda"></param>
/// <param name="keySelector">u=></param>
/// <param name="isAsc"></param>
/// <returns></returns>
public IQueryable<T> WhereOrder<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true)
{
if (isAsc)
return db.Set<T>().Where(whereLambda).OrderBy(keySelector);
else
return db.Set<T>().Where(whereLambda).OrderByDescending(keySelector);
}
#endregion #region 4.2 查询方法 -带Include +IQueryable<T> WhereInclude
/// <summary>
/// 4.2 查询方法 -带Include
/// </summary>
/// <param name="whereLambda"></param>
/// <param name="includePropertyNames">要进行连接查询的 属性名</param>
/// <returns></returns>
public IQueryable<T> WhereInclude(Expression<Func<T, bool>> whereLambda, params string[] includePropertyNames)
{
DbQuery<T> dbQuery = db.Set<T>();
foreach (string includeName in includePropertyNames)
{
dbQuery = dbQuery.Include(includeName);
}
return dbQuery.Where(whereLambda); //DbQuery<T> dbSet = (DbQuery<T>)db.Set<T>().Where(whereLambda);
//foreach (string includeName in includePropertyNames)
//{
// dbSet = dbSet.Include(includeName);
//}
//return dbSet;
}
#endregion #region 4.3 查询方法 -带Include 和 排序 +IQueryable<T> WhereInclude<TKey>
/// <summary>
/// 4.3 查询方法 -带Include 和 排序
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <param name="whereLambda"></param>
/// <param name="keySelector"></param>
/// <param name="isAsc"></param>
/// <param name="includePropertyNames"></param>
/// <returns></returns>
public IQueryable<T> WhereInclude<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames)
{
DbQuery<T> dbQuery = db.Set<T>();
if (includePropertyNames != null && includePropertyNames.Length > )
{
foreach (string includeName in includePropertyNames)
{
dbQuery = dbQuery.Include(includeName);
}
}
IQueryable<T> query = dbQuery.Where(whereLambda);
if (isAsc)
return query.OrderBy(keySelector);
else
return query.OrderByDescending(keySelector);
}
#endregion #region 4.4 查询方法 - 分页+Include+排序 + void WherePaged<TKey>
/// <summary>
/// 4.4 查询方法 - 分页+Include+排序
/// </summary>
/// <typeparam name="TKey"></typeparam>
/// <param name="pagedData"></param>
/// <param name="whereLambda"></param>
/// <param name="keySelector"></param>
/// <param name="isAsc"></param>
/// <param name="includePropertyNames"></param>
public IEnumerable<T> WherePaged<TKey>(int PageIndex, int PageSize, out int totalCount, Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames)
{
//0.获取 要操作的 数据表 对应的查询对象
DbQuery<T> dbQuery = db.Set<T>();
if (includePropertyNames != null && includePropertyNames.Length > )
{
foreach (string includeName in includePropertyNames)
{
dbQuery = dbQuery.Include(includeName);
}
} IOrderedQueryable<T> orderQuery = null;
//2.排序
if (isAsc) { orderQuery = dbQuery.OrderBy(keySelector); }
else { orderQuery = dbQuery.OrderByDescending(keySelector); }
//3.分页查询
var list = orderQuery.Where(whereLambda).Skip((PageIndex - ) * PageSize).Take(PageSize).ToList();
//4.获取总行数
totalCount = orderQuery.Where(whereLambda).Count();
return list;
}
#endregion #region 4.5 查询方法 QueryBySql(string sql, params System.Data.SqlClient.SqlParameter[] ps) SQl语句的查询方法
public IQueryable<T> QueryBySql(string sql, params System.Data.SqlClient.SqlParameter[] ps)
{
return db.Database.SqlQuery<T>(sql, ps).AsQueryable();
}
#endregion
}
}
T4模板生成的代码如下:
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
<#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, );
MetadataTools ef = new MetadataTools(this);
string inputFile1 = @"E:\Temp\test01\3LaySolution\C10.ZRF.Model\Model1.edmx";
EdmItemCollection ItemCollection1 = loader.CreateEdmItemCollection(inputFile1);
string namespaceName = code.VsNamespaceSuggestion();
EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C01.ZRF.IDAL;
using C10.ZRF.Model; namespace C01.ZRF.DAL
{
<#
foreach (EntityType entity in ItemCollection1.GetItems<EntityType>().OrderBy(e => e.Name))
{
#>
public partial class <#=entity.Name#>_DAL : BaseDAL<<#=entity.Name#>>,I<#=entity.Name#>_DAL{ }
<#}#>
}
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C01.ZRF.IDAL;
using C10.ZRF.Model; namespace C01.ZRF.DAL
{
public partial class BuyCar_DAL : BaseDAL<BuyCar>,IBuyCar_DAL{ }
public partial class Menu_DAL : BaseDAL<Menu>,IMenu_DAL{ }
public partial class Product_DAL : BaseDAL<Product>,IProduct_DAL{ }
public partial class Role_DAL : BaseDAL<Role>,IRole_DAL{ }
public partial class roleMenu_DAL : BaseDAL<roleMenu>,IroleMenu_DAL{ }
public partial class uerRole_DAL : BaseDAL<uerRole>,IuerRole_DAL{ }
public partial class User_DAL : BaseDAL<User>,IUser_DAL{ } }
3:IBLL
using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Text;
using System.Threading.Tasks; namespace C01.ZRF.IBLL
{
public interface IBaseBLL<T>where T:class
{
int SaveChanges(); void Add(T model); void Delete(T model); void DeleteBy(Expression<Func<T, bool>> delWhere); void Modify(T model, params string[] propertyNames); IQueryable<T> Where(Expression<Func<T, bool>> whereLambda); IQueryable<T> WhereOrder<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true); IQueryable<T> WhereInclude(Expression<Func<T, bool>> whereLambda, params string[] includePropertyNames); IQueryable<T> WhereInclude<TKey>(Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames); IEnumerable<T> WherePaged<TKey>(int PageIndex, int PageSize, out int totalCount, Expression<Func<T, bool>> whereLambda, Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames); IQueryable<T> QueryBySql(string sql, params System.Data.SqlClient.SqlParameter[] ps);
}
}
T4代码生成器:
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
<#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, );
MetadataTools ef = new MetadataTools(this);
string inputFile1 = @"E:\Temp\test01\3LaySolution\C10.ZRF.Model\Model1.edmx";
EdmItemCollection ItemCollection1 = loader.CreateEdmItemCollection(inputFile1);
string namespaceName = code.VsNamespaceSuggestion();
EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C10.ZRF.Model; namespace C01.ZRF.IBLL
{
<#
foreach (EntityType entity in ItemCollection1.GetItems<EntityType>().OrderBy(e => e.Name))
{
#>
public partial interface I<#=entity.Name#>_BLL : IBaseBLL<<#=entity.Name#>>{ }
<#}#>
}
效果如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C10.ZRF.Model; namespace C01.ZRF.IBLL
{
public partial interface IBuyCar_BLL : IBaseBLL<BuyCar>{ }
public partial interface IMenu_BLL : IBaseBLL<Menu>{ }
public partial interface IProduct_BLL : IBaseBLL<Product>{ }
public partial interface IRole_BLL : IBaseBLL<Role>{ }
public partial interface IroleMenu_BLL : IBaseBLL<roleMenu>{ }
public partial interface IuerRole_BLL : IBaseBLL<uerRole>{ }
public partial interface IUser_BLL : IBaseBLL<User>{ } }
4:BLL
using System;
using System.Collections.Generic;
using System.Linq; namespace C01.ZRF.BLL
{
using C01.ZRF.IBLL;
using C01.ZRF.IDAL;
using System.Data.SqlClient;
public partial class BaseBLL<T> : IBaseBLL<T> where T : class
{
protected IBaseDAL<T> basedal;
public void Add(T model)
{
basedal.Add(model);
} public void Delete(T model)
{
basedal.Delete(model);
} public void DeleteBy(System.Linq.Expressions.Expression<Func<T, bool>> delWhere)
{
basedal.DeleteBy(delWhere);
} public void Modify(T model, params string[] propertyNames)
{
basedal.Modify(model, propertyNames);
} public IQueryable<T> QueryBySql(string sql, params SqlParameter[] ps)
{
return basedal.QueryBySql(sql, ps);
} public int SaveChanges()
{
return basedal.SaveChanges();
} public IQueryable<T> Where(System.Linq.Expressions.Expression<Func<T, bool>> whereLambda)
{
return basedal.Where(whereLambda);
} public IQueryable<T> WhereInclude(System.Linq.Expressions.Expression<Func<T, bool>> whereLambda, params string[] includePropertyNames)
{
return basedal.WhereInclude(whereLambda, includePropertyNames);
} public IQueryable<T> WhereInclude<TKey>(System.Linq.Expressions.Expression<Func<T, bool>> whereLambda, System.Linq.Expressions.Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames)
{
return basedal.WhereInclude<TKey>(whereLambda, keySelector, isAsc, includePropertyNames);
} public IQueryable<T> WhereOrder<TKey>(System.Linq.Expressions.Expression<Func<T, bool>> whereLambda, System.Linq.Expressions.Expression<Func<T, TKey>> keySelector, bool isAsc = true)
{
return basedal.WhereOrder<TKey>(whereLambda, keySelector, isAsc);
} public IEnumerable<T> WherePaged<TKey>(int PageIndex, int PageSize, out int totalCount, System.Linq.Expressions.Expression<Func<T, bool>> whereLambda, System.Linq.Expressions.Expression<Func<T, TKey>> keySelector, bool isAsc = true, params string[] includePropertyNames)
{
return basedal.WherePaged<TKey>(PageIndex, PageSize, out totalCount, whereLambda, keySelector, isAsc, includePropertyNames);
}
}
}
T4模板生成器:
<#@ template language="C#" debug="false" hostspecific="true"#>
<#@ include file="EF.Utility.CS.ttinclude"#>
<#@ output extension=".cs"#>
<#
CodeGenerationTools code = new CodeGenerationTools(this);
MetadataLoader loader = new MetadataLoader(this);
CodeRegion region = new CodeRegion(this, );
MetadataTools ef = new MetadataTools(this);
string inputFile1 = @"E:\Temp\test01\3LaySolution\C10.ZRF.Model\Model1.edmx";
EdmItemCollection ItemCollection1 = loader.CreateEdmItemCollection(inputFile1);
string namespaceName = code.VsNamespaceSuggestion();
EntityFrameworkTemplateFileManager fileManager = EntityFrameworkTemplateFileManager.Create(this);
#>
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using C10.ZRF.Model;
using C01.ZRF.IBLL;
using C01.ZRF.IDAL;
namespace C01.ZRF.BLL
{
<#
foreach (EntityType entity in ItemCollection1.GetItems<EntityType>().OrderBy(e => e.Name))
{
#>
public partial class <#=entity.Name#>_BLL : BaseBLL<<#=entity.Name#>>,I<#=entity.Name#>_BLL{
I<#=entity.Name#>_DAL dal;
public <#=entity.Name#>_BLL(I<#=entity.Name#>_DAL dal){
this.dal=dal; base.basedal=dal;
}
}
<#}#>
}
效果如下:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks; namespace C01.ZRF.BLL
{
using C10.ZRF.Model;
using C01.ZRF.IBLL;
using C01.ZRF.IDAL;
public partial class RoleBLL : BaseBLL<Role>, IRole_BLL
{
IRole_DAL dal;
public RoleBLL(IRole_DAL dal) {
this.dal = dal;
base.basedal = dal;
}
}
}
5:AutoFac配置文件内容
using Autofac;
using Autofac.Integration.Mvc;
using System.Reflection; namespace WebApplication1
{
public class AutoFacConfig
{
public static void Register()
{
//1.0 创建一个autofac的容器创建者对象
var builder = new ContainerBuilder(); //2.0 告诉autofac控制器类所存储的程序集是谁
Assembly controllerAss = Assembly.Load("WebApplication1");
builder.RegisterControllers(controllerAss); //3.0 将仓储层中的所有的类实例化以其接口的形式存储起来
Assembly dalAss = Assembly.Load("C01.ZRF.DAL");
builder.RegisterTypes(dalAss.GetTypes()).AsImplementedInterfaces(); //4.0 将业务逻辑层中的所有的类实例化以其接口的形式存储起来
Assembly bllAss = Assembly.Load("C01.ZRF.BLL");
builder.RegisterTypes(bllAss.GetTypes()).AsImplementedInterfaces(); //5.0 告诉MVC底层控制器的对象创建工作被autofac替代
//5.0.1 创建一个真正的autofac工作容器
var c = builder.Build(); //5.0.2 将auto发出工作容器替换MVC底层
System.Web.Mvc.DependencyResolver.SetResolver(new AutofacDependencyResolver(c));
}
}
}
配置后再去Global.asax 全局文件里面注册即可:
protected void Application_Start()
{
AreaRegistration.RegisterAllAreas();
FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
RouteConfig.RegisterRoutes(RouteTable.Routes);
BundleConfig.RegisterBundles(BundleTable.Bundles);
AutoFacConfig.Register();//------ }
6:Web端来调用:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Web.Mvc; namespace WebApplication1.Controllers
{
using C01.ZRF.IBLL;
using C10.ZRF.Model.ModelView;
using COMMOM;
using C10.ZRF.Model.Filter;
using System.Threading.Tasks;
using C10.ZRF.Model; // [WebApplication1._Filters.ZrfComparess]
public class HomeController : Controller
{
public ActionResult DoCombresTest() {
return View();
} #region MyRegion
IBuyCar_BLL bll;
public HomeController(IBuyCar_BLL bll)
{
this.bll = bll;
}
// GET: Home
public ActionResult Index()
{
ViewBag.car = bll.Where(c => c.cid == ).FirstOrDefault().pcount;
ViewBag.time = "时间是=" + DateTime.Now.ToString();
return View();
}
}
}
自己动手搭建经典的3层 Asp.Net MVC的更多相关文章
- Win7环境 搭建IIS环境。发布asp.net MVC项目到IIS(第二期)
在IIS环境中给发布项目修改域名,192.168.1.1:8081 ---->> www.preject.com 一.在网站主页中,1找到绑定网站.2编辑. 二.修改网站配置参数. 三. ...
- Win7环境 搭建IIS环境。发布asp.net MVC项目到IIS(第一期)
一.右键添加网站,输入网站基本配置信息. 二.成功添加网站后,应用程序池里会多一个应用,版本一定要改成4.0,并且模式是集成模式,否则项目报错(原因可以看配置文件中的版本信息). 三.再启用项目时可能 ...
- ASP.NET MVC项目框架快速搭建实战
MVC项目搭建笔记---- 项目框架采用ASP.NET MVC+Entity Framwork+Spring.Net等技术搭建,采用”Domain Model as View Model“的MVC开发 ...
- Unity + iBatis + Asp.net Mvc 系统搭建
Unity + iBatis + Asp.net Mvc 系统搭建 之前用EntityFramework Code First做了一些小项目,很是方便:后来在一个 Java 项目中接触了myBatis ...
- 4、ASP.NET MVC入门到精通——NHibernate构建一个ASP.NET MVC应用程序
下周就去办理离职手续了,之前没有使用过NHibernate,只知道NHibernate是一种ORM框架,但是听说新公司是使用NHibernate在做项目,所以,我就网上找资料学习一下NHibernat ...
- NHibernate构建一个ASP.NET MVC应用程序
NHibernate构建一个ASP.NET MVC应用程序 什么是Nhibernate? NHibernate是一个面向.NET环境的对象/关系数据库映射工具.对象/关系数据库映射(object/re ...
- ASP.NET MVC企业级项目框架
ASP.NET MVC企业级项目框架 MVC项目搭建笔记---- 项目框架采用ASP.NET MVC+Entity Framwork+Spring.Net等技术搭建,搭建过程内容比较多,结合了抽象工厂 ...
- ASP.NET MVC 概述
目标:学习ASP.NET MVC 和ASP.NET WebForm的不同之处.学习在合适的地方使用ASP.NET MVC. MVC(Model-View-Controller)结构模式把一个对象分离成 ...
- asp.net mvc 简单项目框架的搭建过程(一)对Bll层和Dal层进行充分解耦
学习asp.net 已经有近三个月的时间了,在asp.net mvc上花的时间最多,但个人真是有些菜,不得不说,asp.net mvc的水真的还是蛮深的.目前在公司实习,也见过公司几个项目的代码了.对 ...
随机推荐
- python爬虫三大解析库之XPath解析库通俗易懂详讲
目录 使用XPath解析库 @(这里写自定义目录标题) 使用XPath解析库 1.简介 XPath(全称XML Path Languang),即XML路径语言,是一种在XML文档中查找信息的语言. ...
- JS是解释型还是编译型语言?
解释型和编译型语言 解释型语言 解释型语言是对代码进行一句一句的直接运行,在程序运行期间,使用解释器动态将代码解释为机器码,再运行. 编译型语言 编译型语言是需要使用编译器先对代码进行编译为机器码,再 ...
- 创建Npm脚手架
1工具 l Npm ( https://nodejs.org/en/ ) l Yeoman (npm install -g yo) l generator-generator (npm inst ...
- Java 日期处理类
日期处理类 Date类 当前日期时间 java.util.Date import java.util.Date; public class TestDemo { public static void ...
- 用redis和cookie做单用户登录
因为公司的项目需要用到单用户登录,于是今天用redis和cookie给系统添加了单用户登录功能,再次简单记录一下. 单用户登录是为了防止同一账户在不同电脑和不同浏览器里面同时登录.所以我这边的思路是: ...
- Android 矢量图详解
官方文档 关于 Vector,在官方开发指南中介绍.本文章是由个人翻译官方指南然后添加个人理解完成. 由于个人精力有限,多个渠道发布,排版上可能会有问题,如果影响查看,请移步 Android 开发者家 ...
- Linux使用Samba实现文件共享
Samba服务是现在Linux系统与Windows系统之间共享文件的最佳选择. [root@study ~]# yum install samba -y #安装samba服务 [root@study ...
- 爬虫scrapy组件 请求传参,post请求,中间件
post请求 在scrapy组件使用post请求需要调用 def start_requests(self): 进行传参再回到 yield scrapy.FormRequest(url=url,form ...
- Python常用数据类型简介
1.变量的三个基本特征 1,大印 2,判断变量值是否相等 3,判断变量id是否相等 2.常用数据类型分类 数字类型(int) 字符串类型(str) 列表类型(list) 字典类型(dict(dicti ...
- (转)SpringMVC表单多对象传递小技巧——@InitBinder
转:https://www.jianshu.com/p/59771cbf373d 1.问题情景 项目中前端后台的数据传递是必不可少的,比如说我们要在一张表单中提交对象,如果只是一个对象就就很好做,因为 ...