1-UI,登陆界面布局

PS:使用的是metronic 框架,没有用过的可以自行百度。

1.1 metronic 放在wwwroot文件夹下面

1.2  metronic 中的 open sans 使用的是 谷歌的DNS,所以我们需要自己下载本地资源(使用nuget管理器下载,也可以用nuget控制台)。

1.3 创建Account控制器和视图 ,由于现在不支持在controller中直接右击生成视图文件,因此我们需要自己在Views文件下创建Account文件夹和Login.cshtml文件。

1.3.1 在Account 中创建布局页面Layout.cshtml

 <!DOCTYPE html>
<!--[if IE 8]> <html lang="en" class="ie8 no-js"> <![endif]-->
<!--[if IE 9]> <html lang="en" class="ie9 no-js"> <![endif]-->
<!--[if !IE]><!-->
<html lang="en">
<!--<![endif]-->
<!-- BEGIN HEAD -->
<head>
<meta charset="utf-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<meta content="" name="description" />
<meta content="" name="author" />
<title>@ViewData["Title"] - NET Core Demo</title>
<environment names="Development">
<link rel="stylesheet" href="~/css/font-open-sans.css" />
<link href="~/metronic/assets/global/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css" />
<link href="~/metronic/assets/global/plugins/bootstrap/css/bootstrap.css" rel="stylesheet" type="text/css" />
<link href="~/metronic/assets/global/css/components.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="~/metronic/assets/pages/css/login.css" rel="stylesheet" type="text/css" />
</environment>
<environment names="Staging,Production">
<link rel="stylesheet" href="http://fonts.googleapis.com/css?family=Open+Sans:400,300,600,700&subset=all"
asp-fallback-href="~/css/font-open-sans.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link href="~/metronic/assets/global/plugins/font-awesome/css/font-awesome.css" rel="stylesheet" type="text/css" />
<link rel="stylesheet" href="https://ajax.aspnetcdn.com/ajax/bootstrap/3.3.6/css/bootstrap.min.css"
asp-fallback-href="~/lib/bootstrap/dist/css/bootstrap.min.css"
asp-fallback-test-class="sr-only" asp-fallback-test-property="position" asp-fallback-test-value="absolute" />
<link href="~/metronic/assets/global/css/components.min.css" rel="stylesheet" id="style_components" type="text/css" />
<link href="~/metronic/assets/pages/css/login.min.css" rel="stylesheet" type="text/css" />
</environment>
@RenderSection("css", required: false)
@Html.ApplicationInsightsJavaScript(TelemetryConfiguration)
</head>
<body class="login">
<div class="logo">
<a href="index.html">
<img src="~/metronic/assets/pages/img/logo-big.png" alt="" />
</a>
</div>
<div class="content">
@RenderBody()
</div>
<div class="copyright">2014 © Metronic. Admin Dashboard Template.</div>
<!--[if lt IE 9]>
<script src="~/metronic/assets/global/plugins/respond.min.js"></script>
<script src="~/metronic/assets/global/plugins/excanvas.min.js"></script>
<![endif]-->
<script src="~/metronic/assets/global/plugins/jquery.min.js" type="text/javascript"></script>
<script src="~/metronic/assets/global/plugins/bootstrap/js/bootstrap.min.js" type="text/javascript"></script>
@*<script src="~/metronic/assets/global/plugins/js.cookie.min.js" type="text/javascript"></script>*@
<script src="~/metronic/assets/global/plugins/jquery-validation/js/jquery.validate.min.js" type="text/javascript"></script>
@*<script src="~/metronic/assets/global/plugins/jquery-validation/js/additional-methods.min.js" type="text/javascript"></script>*@
<script src="~/metronic/assets/global/scripts/app.min.js" type="text/javascript"></script> @RenderSection("scripts", required: false)
</body>
</html>

Layout.cshtml

1.3.2 login登陆页面

 <form class="login-form" asp-action="Login" asp-controller="Account" method="post">
@Html.AntiForgeryToken()
<h3 class="form-title font-green">登录</h3>
<div class="alert alert-danger display-hide">
<button class="close" data-close="alert"></button>
<span> 请输入用户名或密码. </span>
</div>
@if (ViewBag.IsInvalid)
{
<div class="alert alert-danger">
<button class="close" data-close="alert"></button>
<span> @ViewBag.ErrorMsg. </span>
</div>
}
<div class="form-group">
<!--ie8, ie9 does not support html5 placeholder, so we just show field title for that-->
<label class="control-label visible-ie8 visible-ie9">用户名</label>
<input class="form-control form-control-solid placeholder-no-fix" type="text" autocomplete="off" placeholder="用户名" name="username" />
</div>
<div class="form-group">
<label class="control-label visible-ie8 visible-ie9">密码</label>
<input class="form-control form-control-solid placeholder-no-fix" type="password" autocomplete="off" placeholder="密码" name="password" />
</div>
<div class="form-actions">
<button type="submit" class="btn green uppercase">登录</button>
<label class="rememberme check">
<input type="checkbox" name="remember" value="1" />记住密码
</label>
<a asp-area="" asp-controller="Account" asp-action="ForgetPassword" id="forget-password" class="forget-password">忘记密码?</a>
</div>
<input hidden id="returnUrl" name="returnUrl" value="@ViewBag.ReturnUrl" />
</form>
@section scripts{
<environment names="Development">
<script src="~/js/account/login.js" type="text/javascript"></script>
</environment>
<environment names="Staging,Production">
<script src="~/js/account/login.min.js" type="text/javascript"></script>
</environment>
}

Login.cshtml

1.3.3 配置文件压缩机制bundleconfig.json (压缩文件只有当你发布系统的时候才会生成,DEBUG的时候不会生成)。

2- 登录代码实现,依赖注册

2.1 GR.Core中创建IRepository通用仓储接口(该代码来自ABP的实现,我自己有修改)。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using GR.Core.Domain; namespace GR.Core.Data
{
/// <summary>
/// Repository
/// </summary>
public partial interface IRepository<TEntity> :IRepository<TEntity, int> where TEntity : BaseEntity
{ } /// <summary>
/// This interface is implemented by all repositories to ensure implementation of fixed methods.
/// </summary>
/// <remarks>
/// 参考ABP实现 https://github.com/aspnetboilerplate
/// </remarks>
/// <typeparam name="TEntity">Main Entity type this repository works on</typeparam>
/// <typeparam name="TPrimaryKey">Primary key type of the entity</typeparam>
public interface IRepository<TEntity, TPrimaryKey> where TEntity : BaseEntity
{
#region Select/Get/Query /// <summary>
/// Used to get a IQueryable that is used to retrieve entities from entire table.
/// <see cref="UnitOfWorkAttribute"/> attribute must be used to be able to call this method since this method
/// returns IQueryable and it requires open database connection to use it.
/// </summary>
/// <returns>IQueryable to be used to select entities from database</returns>
IQueryable<TEntity> GetAll(); /// <summary>
/// Used to get all entities.
/// </summary>
/// <returns>List of all entities</returns>
List<TEntity> GetAllList(); /// <summary>
/// Used to get all entities.
/// </summary>
/// <returns>List of all entities</returns>
Task<List<TEntity>> GetAllListAsync(); /// <summary>
/// Used to get all entities based on given <paramref name="predicate"/>.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
/// <returns>List of all entities</returns>
List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Used to get all entities based on given <paramref name="predicate"/>.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
/// <returns>List of all entities</returns>
Task<List<TEntity>> GetAllListAsync(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Used to run a query over entire entities.
/// <see cref="UnitOfWorkAttribute"/> attribute is not always necessary (as opposite to <see cref="GetAll"/>)
/// if <paramref name="queryMethod"/> finishes IQueryable with ToList, FirstOrDefault etc..
/// </summary>
/// <typeparam name="T">Type of return value of this method</typeparam>
/// <param name="queryMethod">This method is used to query over entities</param>
/// <returns>Query result</returns>
T Query<T>(Func<IQueryable<TEntity>, T> queryMethod); /// <summary>
/// Gets an entity with given primary key.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity</returns>
TEntity Get(TPrimaryKey id); /// <summary>
/// Gets an entity with given primary key.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity</returns>
Task<TEntity> GetAsync(TPrimaryKey id); /// <summary>
/// Gets exactly one entity with given predicate.
/// Throws exception if no entity or more than one entity.
/// </summary>
/// <param name="predicate">Entity</param>
TEntity Single(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets exactly one entity with given predicate.
/// Throws exception if no entity or more than one entity.
/// </summary>
/// <param name="predicate">Entity</param>
Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets an entity with given primary key or null if not found.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
TEntity FirstOrDefault(TPrimaryKey id); /// <summary>
/// Gets an entity with given primary key or null if not found.
/// </summary>
/// <param name="id">Primary key of the entity to get</param>
/// <returns>Entity or null</returns>
Task<TEntity> FirstOrDefaultAsync(TPrimaryKey id); /// <summary>
/// Gets an entity with given given predicate or null if not found.
/// </summary>
/// <param name="predicate">Predicate to filter entities</param>
TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets an entity with given given predicate or null if not found.
/// </summary>
/// <param name="predicate">Predicate to filter entities</param>
Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Creates an entity with given primary key without database access.
/// </summary>
/// <param name="id">Primary key of the entity to load</param>
/// <returns>Entity</returns>
TEntity Load(TPrimaryKey id); #endregion /// <summary>
/// Inserts a new entity.
/// </summary>
/// <param name="entity">Inserted entity</param>
int Insert(TEntity entity, bool IsCommit = true); /// <summary>
/// Inserts a new entity.
/// </summary>
/// <param name="entity">Inserted entity</param>
Task<int> InsertAsync(TEntity entity, bool IsCommit = true); /// <summary>
/// Inserts or updates given entity depending on Id's value.
/// </summary>
/// <param name="entity">Entity</param>
int InsertOrUpdate(TEntity entity, bool IsCommit = true); /// <summary>
/// Inserts or updates given entity depending on Id's value.
/// </summary>
/// <param name="entity">Entity</param>
Task<int> InsertOrUpdateAsync(TEntity entity, bool IsCommit = true); /// <summary>
/// Updates an existing entity.
/// </summary>
/// <param name="entity">Entity</param>
int Update(TEntity entity, bool IsCommit = true); /// <summary>
/// Updates an existing entity.
/// </summary>
/// <param name="entity">Entity</param>
Task<int> UpdateAsync(TEntity entity, bool IsCommit = true); /// <summary>
/// Deletes an entity.
/// </summary>
/// <param name="entity">Entity to be deleted</param>
int Delete(TEntity entity, bool IsCommit = true); /// <summary>
/// Deletes an entity.
/// </summary>
/// <param name="entity">Entity to be deleted</param>
Task DeleteAsync(TEntity entity, bool IsCommit = true); /// <summary>
/// Deletes an entity by primary key.
/// </summary>
/// <param name="id">Primary key of the entity</param>
int Delete(TPrimaryKey id, bool IsCommit = true); /// <summary>
/// Deletes an entity by primary key.
/// </summary>
/// <param name="id">Primary key of the entity</param>
Task DeleteAsync(TPrimaryKey id, bool IsCommit = true); /// <summary>
/// Deletes many entities by function.
/// Notice that: All entities fits to given predicate are retrieved and deleted.
/// This may cause major performance problems if there are too many entities with
/// given predicate.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
void Delete(Expression<Func<TEntity, bool>> predicate, bool IsCommit = true); /// <summary>
/// Deletes many entities by function.
/// Notice that: All entities fits to given predicate are retrieved and deleted.
/// This may cause major performance problems if there are too many entities with
/// given predicate.
/// </summary>
/// <param name="predicate">A condition to filter entities</param>
Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool IsCommit = true); #region Aggregates /// <summary>
/// Gets count of all entities in this repository.
/// </summary>
/// <returns>Count of entities</returns>
int Count(); /// <summary>
/// Gets count of all entities in this repository.
/// </summary>
/// <returns>Count of entities</returns>
Task<int> CountAsync(); /// <summary>
/// Gets count of all entities in this repository based on given <paramref name="predicate"/>.
/// </summary>
/// <param name="predicate">A method to filter count</param>
/// <returns>Count of entities</returns>
int Count(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets count of all entities in this repository based on given <paramref name="predicate"/>.
/// </summary>
/// <param name="predicate">A method to filter count</param>
/// <returns>Count of entities</returns>
Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets count of all entities in this repository (use if expected return value is greather than <see cref="int.MaxValue"/>.
/// </summary>
/// <returns>Count of entities</returns>
long LongCount(); /// <summary>
/// Gets count of all entities in this repository (use if expected return value is greather than <see cref="int.MaxValue"/>.
/// </summary>
/// <returns>Count of entities</returns>
Task<long> LongCountAsync(); /// <summary>
/// Gets count of all entities in this repository based on given <paramref name="predicate"/>
/// (use this overload if expected return value is greather than <see cref="int.MaxValue"/>).
/// </summary>
/// <param name="predicate">A method to filter count</param>
/// <returns>Count of entities</returns>
long LongCount(Expression<Func<TEntity, bool>> predicate); /// <summary>
/// Gets count of all entities in this repository based on given <paramref name="predicate"/>
/// (use this overload if expected return value is greather than <see cref="int.MaxValue"/>).
/// </summary>
/// <param name="predicate">A method to filter count</param>
/// <returns>Count of entities</returns>
Task<long> LongCountAsync(Expression<Func<TEntity, bool>> predicate); #endregion
}
}

IRepository

2.2 GR.Data中创建EFRepository通用仓储实现(该代码来自ABP的实现,我自己有修改)。

 using System;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
using System.Threading.Tasks;
using GR.Core.Data;
using GR.Core.Domain;
using Microsoft.EntityFrameworkCore; namespace GR.Data.Repository
{
/// <summary>
///
/// </summary>
/// <typeparam name="TEntity"></typeparam>
public class EfRepository<TEntity> : EfRepositoryBase<GRDbContext, TEntity, int>, IRepository<TEntity> where TEntity : BaseEntity
{
public EfRepository(GRDbContext dbContext) : base(dbContext)
{ }
} /// <summary>
/// 通用仓储基类
/// </summary>
/// <remarks>
/// 参考了 ABP 的 仓储基类
/// https://github.com/aspnetboilerplate
/// </remarks>
/// <typeparam name="TDbContext"></typeparam>
/// <typeparam name="TEntity"></typeparam>
/// <typeparam name="TPrimaryKey"></typeparam>
public abstract class EfRepositoryBase<TDbContext, TEntity, TPrimaryKey>
where TDbContext : DbContext
where TEntity : BaseEntity
{
private readonly TDbContext _dbContext; public EfRepositoryBase(TDbContext dbContext)
{
_dbContext = dbContext;
} /// <summary>
/// Gets DbSet for given entity.
/// </summary>
public virtual DbSet<TEntity> Table
{
get
{
return _dbContext.Set<TEntity>();
}
} /// <summary>
/// Gets EF DbContext object.
/// </summary>
public virtual TDbContext DbContext
{
get { return _dbContext; }
} public IQueryable<TEntity> GetAll()
{
return Table;
} public TEntity FirstOrDefault(TPrimaryKey id)
{
return GetAll().FirstOrDefault(CreateEqualityExpressionForId(id));
} public List<TEntity> GetAllList()
{
return Table.ToList();
} public List<TEntity> GetAllList(Expression<Func<TEntity, bool>> predicate)
{
return Table.Where(predicate).ToList();
} public async Task<List<TEntity>> GetAllListAsync()
{
return await GetAll().ToListAsync();
} public async Task<List<TEntity>> GetAllListAsync(Expression<Func<TEntity, bool>> predicate)
{
return await GetAll().Where(predicate).ToListAsync();
} public T Query<T>(Func<IQueryable<TEntity>, T> queryMethod)
{
return queryMethod(GetAll());
} public TEntity Get(TPrimaryKey id)
{
var entity = FirstOrDefault(id);
if (entity == null)
{
throw new ArgumentNullException("There is no such an entity with given primary key. Entity type: " + typeof(TEntity).FullName + ", primary key: " + id);
}
return entity;
} public async Task<TEntity> GetAsync(TPrimaryKey id)
{
var entity = await FirstOrDefaultAsync(id);
if (entity == null)
{
throw new ArgumentNullException("There is no such an entity with given primary key. Entity type: " + typeof(TEntity).FullName + ", primary key: " + id);
} return entity;
} public TEntity Single(Expression<Func<TEntity, bool>> predicate)
{
return GetAll().Single(predicate);
} public async Task<TEntity> SingleAsync(Expression<Func<TEntity, bool>> predicate)
{
return await GetAll().SingleAsync(predicate);
} public async Task<TEntity> FirstOrDefaultAsync(TPrimaryKey id)
{
return await GetAll().FirstOrDefaultAsync(CreateEqualityExpressionForId(id));
} public async Task<TEntity> FirstOrDefaultAsync(Expression<Func<TEntity, bool>> predicate)
{
return await GetAll().FirstOrDefaultAsync(predicate);
} public int Insert(TEntity entity, bool IsCommit = true)
{
Table.Add(entity);
return IsCommit ? _dbContext.SaveChanges() : -;
} public Task<int> InsertAsync(TEntity entity, bool IsCommit = true)
{
Table.Add(entity);
return IsCommit ? Task.FromResult(_dbContext.SaveChanges()) : Task.FromResult(-);
} public int Update(TEntity entity, bool IsCommit = true)
{
AttachIfNot(entity);
_dbContext.Entry(entity).State = EntityState.Modified;
return IsCommit ? _dbContext.SaveChanges() : -;
} public Task<int> UpdateAsync(TEntity entity, bool IsCommit = true)
{
AttachIfNot(entity);
_dbContext.Entry(entity).State = EntityState.Modified;
return IsCommit ? Task.FromResult(_dbContext.SaveChanges()) : Task.FromResult(-);
} public int InsertOrUpdate(TEntity entity, bool IsCommit = true)
{
return entity.IsTransient() ? Insert(entity, IsCommit) : Update(entity, IsCommit);
} public async Task<int> InsertOrUpdateAsync(TEntity entity, bool IsCommit = true)
{
return entity.IsTransient() ? await InsertAsync(entity, IsCommit) : await UpdateAsync(entity, IsCommit);
} public int Delete(TEntity entity, bool IsCommit = true)
{
AttachIfNot(entity);
Table.Remove(entity);
return IsCommit ? _dbContext.SaveChanges() : -;
} public int Delete(TPrimaryKey id, bool IsCommit = true)
{
var entity = FirstOrDefault(id);
if (entity == null)
{
return ;
}
return Delete(entity, IsCommit);
} public Task DeleteAsync(TEntity entity, bool IsCommit = true)
{
return Task.FromResult(Delete(entity, IsCommit));
} public Task DeleteAsync(TPrimaryKey id, bool IsCommit = true)
{
return Task.FromResult(Delete(id, IsCommit));
} public void Delete(Expression<Func<TEntity, bool>> predicate, bool IsCommit = true)
{
var entities = GetAll().Where(predicate).ToList();
entities.ForEach(entity =>
{
Delete(entity, IsCommit);
});
} public Task DeleteAsync(Expression<Func<TEntity, bool>> predicate, bool IsCommit = true)
{
Delete(predicate, IsCommit);
return Task.FromResult();
}
public async Task<int> CountAsync()
{
return await GetAll().CountAsync();
} public async Task<int> CountAsync(Expression<Func<TEntity, bool>> predicate)
{
return await GetAll().Where(predicate).CountAsync();
} public async Task<long> LongCountAsync()
{
return await GetAll().LongCountAsync();
} public async Task<long> LongCountAsync(Expression<Func<TEntity, bool>> predicate)
{
return await GetAll().Where(predicate).LongCountAsync();
} protected static Expression<Func<TEntity, bool>> CreateEqualityExpressionForId(TPrimaryKey id)
{
var lambdaParam = Expression.Parameter(typeof(TEntity)); var lambdaBody = Expression.Equal(
Expression.PropertyOrField(lambdaParam, "Id"),
Expression.Constant(id, typeof(TPrimaryKey))
); return Expression.Lambda<Func<TEntity, bool>>(lambdaBody, lambdaParam);
} protected void AttachIfNot(TEntity entity)
{
//if (!Table.Local.Contains(entity))
//{
// Table.Attach(entity);
//}
Table.Attach(entity);
} public int Commit()
{
return _dbContext.SaveChanges();
} public async Task<int> CommitAsync()
{
return await _dbContext.SaveChangesAsync();
} public TEntity FirstOrDefault(Expression<Func<TEntity, bool>> predicate)
{
return GetAll().FirstOrDefault(predicate);
} public TEntity Load(TPrimaryKey id)
{
return Get(id);
} public int Count()
{
return GetAll().Count();
} public int Count(Expression<Func<TEntity, bool>> predicate)
{
return GetAll().Where(predicate).Count();
} public long LongCount()
{
return GetAll().LongCount();
} public long LongCount(Expression<Func<TEntity, bool>> predicate)
{
return GetAll().Where(predicate).LongCount();
} }
}

EFRepository

2.3 GR.Data中创建DependencyRegister依赖注册类(从Startup中分解出来)

之后只要是在Data中添加的类需要依赖注入,都是在该类中添加

 using System;
using GR.Core.Data;
using GR.Data.Repository;
using Microsoft.EntityFrameworkCore;
using Microsoft.Extensions.DependencyInjection; namespace GR.Data
{
public class DependencyRegister
{
public static void ConfigureServices(IServiceCollection services)
{
services.AddDbContext<GRDbContext>(ServiceLifetime.Singleton);
services.AddScoped(typeof(IRepository<>), typeof(EfRepository<>));
}
}
}

DependencyRegister

2.3 GR.Servies中创建AccountService类,创建DTO实体模型,以及DependencyRegister依赖注册类

2.4 在gr.web中的startup添加依赖注册

3-结束

这样子登陆功能就完成了,其他的数据验证和.NET FRAMEWORK的一样

一个简单的NetCore项目:2 - 登录的更多相关文章

  1. 一个简单的NetCore项目:1 - 搭建框架,生成数据库

    1- 启动项目 安装.NETCORE SDK,教程在网上可以搜索的到,这里就不讲述了.简单粗暴的方式就是安装最新的VS2015. 2-搭建框架 2.1 打开VS新建一个项目,在弹出的新建项目对话框中, ...

  2. Django入门第一步:构建一个简单的Django项目

    Django入门第一步:构建一个简单的Django项目 1.简介 Django是一个功能完备的Python Web框架,可用于构建复杂的Web应用程序.在本文中,将通过示例跳入并学习Django.您将 ...

  3. 一个简单的JUnit项目

    本人一直很喜欢JAVA,可是真正接触到JUnit也不过半年.由于公司进行网页测试,采用的是 JUnit+selenium的方式搭建的测试框架,然后采用JAVA语言编写,所以本人也好好研究了一下JUni ...

  4. 搭建Vue.js环境,建立一个简单的Vue项目

    基于vue-cli快速构建 Vue是近年来比较火的一个前端框架,所以搭建Vue.js环境,要装webpack,vue-cli,Vue 安装webpack命令如下 $ cnpm install webp ...

  5. 通过myclipse建立一个简单的Hibernate项目(PS:在单元测试中实现数据的向表的插入)

    Hibernate的主要功能及用法: Ⅰ.Hibernate封装了JDBC,使Java程序员能够以面向对象的思想对数据库进行操作 Ⅱ.Hibernate可以应用于EJB的J2EE架构,完成数据的持久化 ...

  6. 用 Eclipse 创建一个简单的web项目

    Eclipse neon 汉化版 ; 1;右击新建 -->  选择 动态Web项目 2:  填写 项目名 项目位置 ; 选择 Dynamic web module version 和 tomca ...

  7. 使用一个Python脚本来运行一个简单的Django项目

    创建视图 Django是一个模型-模板-视图(model-template-view,MTV)框架. 视图部分通常检查看HTTP给出的请求和查询或者结构,这些信息是发送到表示层的数据. 我们在 hel ...

  8. JAVA WEB快速入门之通过一个简单的Spring项目了解Spring的核心(AOP、IOC)

    接上篇<JAVA WEB快速入门之从编写一个JSP WEB网站了解JSP WEB网站的基本结构.调试.部署>,通过一个简单的JSP WEB网站了解了JAVA WEB相关的知识,比如:Ser ...

  9. 一个简单的nodejs项目(cat-names)分析

    https://github.com/sindresorhus/cat-names 一个非常简单的nodejs项目,用来方便的获取猫猫的名字: 安装: npm install --save cat-n ...

随机推荐

  1. js实现图片点击弹出放大效果

    点击图片,显示蒙板,放大图片的简单案例 HTML代码: <div> <img height=" src="https://img-blog.csdn.net/20 ...

  2. JS中对象继承方式

    JS对象继承方式 摘自<JavaScript的对象继承方式,有几种写法>,作者:peakedness 链接:https://my.oschina.net/u/3970421/blog/28 ...

  3. 快速玩转linux(1)

    快速上手Linux玩转典型应用 mark 大牛都会使用Linux, Linux命令是行业要求. 商业服务器基本都是linux 开源软件都先支持Linux(只支持) 大数据分析.机器学习首选Linux ...

  4. MyBatis模糊查询的三种拼接方式

    1. sql中字符串拼接 SELECT * FROM tableName WHERE name LIKE CONCAT(CONCAT('%', #{text}), '%'); 2. 使用 ${...} ...

  5. jquery图片滚动animate.css

    @charset "UTF-8"; /*!Animate.css - http://daneden.me/animateLicensed under the MIT license ...

  6. php 移动或重命名文件(图片)到另一目录下的方法有多种,这里只列出三种:

    php 移动或重命名文件(图片)到另一目录下的方法有多种,这里只列出三种:       方法一:使用copy函数   格式:copy(source,destination)   将文件从 source ...

  7. python 面向对象 (多态)

    什么是多态?多态就像是人有多种心情,场景不一样心情就会不一样. class Dog: def print_self(self): print('this is dog') class Hsq(Dog) ...

  8. STL——泛型编程

    1.指针的算术运算 对于一个存储int数据的vector,我们要查找某值是否存在于其中,采用下标操作的做法如下: int* find(const vector<int> &vec, ...

  9. java基础day05---界面

    java基础day05---界面 1.GUI:图形用户界面(Graphics User Interface) 开发工具包AWT抽象窗口把工具箱===>swing 解决了awt存在的lcd问题== ...

  10. [转]URL传中文参数导致乱码的解决方案之encodeURI

    通过URL传中文参数时,在服务端后台获取到的值往往会出现乱码.解决方案有很多种.本文介绍如何通过encodeURI来解决中文乱码问题. 首先,在前端页面准备参数的时候,需要对中文参数进行encode处 ...