首页 文章 精选 留言 我的

精选列表

搜索[Spring Framework],共10000篇文章
优秀的个人博客,低调大师

Entity FrameWork操作数据库完成登陆、列表显示+验证码

2 --> 登陆页面登陆页面的页面结构比较简单,没有写样式。image标签的作用是用来显示验证码。一般处理程序代码展示 using System; using System.Collections.Generic; using System.Drawing; using System.Linq; using System.Web; using System.Web.SessionState; namespace EF_lainxi.BLL { /// <summary> /// Handler1 的摘要说明 /// </summary> public class Handler1 : IHttpHandler, IRequiresSessionState { public void Proce***equest(HttpContext context) { //颜色的集合 Color[] colors = { Color.White }; Image img = new Bitmap(100, 30); Graphics graphics = Graphics.FromImage(img); Random random = new Random(DateTime.Now.Millisecond); int charNum1 = random.Next(97, 122); int charNum2 = random.Next(97, 122); int charNum3 = random.Next(97, 122); int charNum4 = random.Next(97, 122); string validCode = string.Format($"{(char)charNum1}{(char)charNum2}{(char)charNum3}{(char)charNum4}"); context.Session["yzm"] = validCode; Font font = new Font("宋体", 24); Brush brush1 = new SolidBrush(colors[random.Next(0, colors.Length - 1)]); graphics.DrawString(((char)charNum1).ToString(), font, brush1, 7, -3); Brush brush2 = new SolidBrush(colors[random.Next(0, colors.Length - 1)]); graphics.DrawString(((char)charNum2).ToString(), font, brush2, 26, -9); Brush brush3 = new SolidBrush(colors[random.Next(0, colors.Length - 1)]); graphics.DrawString(((char)charNum3).ToString(), font, brush3, 50, 0); Brush brush4 = new SolidBrush(colors[random.Next(0, colors.Length - 1)]); graphics.DrawString(((char)charNum4).ToString(), font, brush4, 70, -7); context.Response.ContentType = "image/jpeg"; img.Save(context.Response.OutputStream, System.Drawing.Imaging.ImageFormat.Jpeg); graphics.Dispose(); img.Dispose(); } public bool IsReusable { get { return false; } } } } 一般处理程序中用来创建一个验证码的图片显示到页面的image里。 页面成品展示登陆页面代码展示 using EF_lainxi.DAL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace EF_lainxi { public partial class DeptDetail : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string yzm= Session["yzm"].ToString(); if (yzm==TextBox3.Text) { if (TextBox1.Text!=null&&TextBox1.Text!=""&&TextBox2.Text!=null&&TextBox2.Text!="") { //数据库的名字 using (Model2 db=new Model2()) { var name = db.Users.FirstOrDefault(s => s.Name == TextBox1.Text); if (name.Pwd==TextBox2.Text) { //跳转到显示界面 Response.Redirect("xians.aspx"); } else { string strUrl = "<script>alert('账号或密码错误');</script>"; Response.Write(strUrl); } } } else { string strUrl = "<script>alert('账号或密码不能为空');</script>"; Response.Write(strUrl); } } else { string strUrl = "<script>alert('验证码不正确');</script>"; Response.Write(strUrl); } } } } 主要作用是进行了验证码的判断、账号密码的正确与否,成功跳转显示界面,错误进行提示。显示页面页面代码 <%@ Page Language="C#" AutoEventWireup="true" CodeBehind="xians.aspx.cs" Inherits="EF_lainxi.xians" %> <!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head runat="server"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"/> <title></title> <link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.4.1/dist/css/bootstrap.min.css" integrity="sha384-Vkoo8x4CGsO3+Hhxv8T/Q5PaXtkKtu6ug5TOeNV6gBiFeWPGFN9MuhOf23Q9Ifjh" crossorigin="anonymous"> </head> <body> <form id="form1" runat="server"> <div> <div> 图书名称: <asp:TextBox ID="TextBox1" runat="server"></asp:TextBox><asp:Button ID="Button1" runat="server" Text="查询" CssClass="btn btn-link" OnClick="Button1_Click" /></div> <div> <table class="table"> <thead> <tr> <th scope="col">图书编号</th> <th scope="col">图书名称</th> <th scope="col">图书价格</th> <th scope="col">作者</th> <th scope="col">类型</th> <th scope="col">图片</th> <th scope="col">上架时间</th> <th scope="col">操作</th> </tr> </thead> <asp:Repeater ID="Repeater1" runat="server" OnItemCommand="Repeater1_ItemCommand"> <ItemTemplate> <tbody> <tr> <th scope="row"><%# Eval("BookId") %></th> <td><%# Eval("BookName") %></td> <td><%# Eval("Price") %></td> <td><%# Eval("BookAuthor") %></td> <td><%# Eval("TypeId.TyoeName") %></td> <td> <asp:Image ID="Image1" runat="server" ImageUrl='<%# "~/images/"+ Eval("Img") %>' Width="60" Height="60" /></td> <td><%# Eval("Addtime") %></td> <td> <asp:LinkButton ID="LinkButton1" runat="server" CommandArgument='<%# Eval("BookId") %>' CommandName="delete" OnClientClick="return confirm('确定删除吗?')">删除</asp:LinkButton> <asp:LinkButton ID="LinkButton2" runat="server" CommandArgument='<%# Eval("BookId") %>' CommandName="xainq">详情</asp:LinkButton> </td> </tr> </tbody> </ItemTemplate> </asp:Repeater> </table> </div> </div> </form> <script src="https://cdn.jsdelivr.net/npm/jquery@3.4.1/dist/jquery.slim.min.js" integrity="sha384-J6qa4849blE2+poT4WnyKhv5vZF5SrPo0iEjwBvKU7imGFAV0wwj1yYfoRSJoZ+n" crossorigin="anonymous"></script> <script src="https://cdn.jsdelivr.net/npm/popper.js@1.16.0/dist/umd/popper.min.js" integrity="sha384-Q6E9RHvbIyZFJoft+2mJbHaEWldlvI9IOYy5n3zV9zzTtmI3UksdQRVvoxMfooAo" crossorigin="anonymous"></script> </body> </html> 显示页面后台代码 using EF_lainxi.DAL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace EF_lainxi { public partial class xians : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { if (!IsPostBack) { select(); } } private void select() { using (Model2 db = new Model2()) { var list = db.BookInfos.ToList(); Repeater1.DataSource = list; Repeater1.DataBind(); } } protected void Repeater1_ItemCommand(object source, RepeaterCommandEventArgs e) { string pand= e.CommandName; int id = Convert.ToInt32(e.CommandArgument); if (pand== "delete") { using (Model2 db = new Model2()) { var sc= db.BookInfos.FirstOrDefault(s => s.BookId == id); db.BookInfos.Remove(sc); db.SaveChanges(); select(); } } } protected void Button1_Click(object sender, EventArgs e) { using (Model2 db = new Model2()) { Repeater1.DataSource = db.BookInfos.Where(p => p.BookName.Contains(TextBox1.Text)).ToList(); Repeater1.DataBind(); } } } } 登陆页面成品展示注册页面代码 注册页面后台 using EF_lainxi.DAL; using System; using System.Collections.Generic; using System.Linq; using System.Web; using System.Web.UI; using System.Web.UI.WebControls; namespace EF_lainxi { public partial class DeptDetail : System.Web.UI.Page { protected void Page_Load(object sender, EventArgs e) { } protected void Button1_Click(object sender, EventArgs e) { string yzm= Session["yzm"].ToString(); if (yzm==TextBox3.Text) { if (TextBox1.Text!=null&&TextBox1.Text!=""&&TextBox2.Text!=null&&TextBox2.Text!="") { using (Model2 db=new Model2()) { var name = db.Users.FirstOrDefault(s => s.Name == TextBox1.Text); if (name.Pwd==TextBox2.Text) { Response.Redirect("xians.aspx"); } else { string strUrl = "<script>alert('账号或密码错误');</script>"; Response.Write(strUrl); } } } else { string strUrl = "<script>alert('账号或密码不能为空');</script>"; Response.Write(strUrl); } } else { string strUrl = "<script>alert('验证码不正确');</script>"; Response.Write(strUrl); } } protected void Button2_Click(object sender, EventArgs e) { Response.Redirect("tianjia.aspx"); } } } 成功后跳转到登陆页面

优秀的个人博客,低调大师

SharePoint Framework 在web部件中使用已存在的JavaScript库 - 捆绑打包和外部引用

博客地址:http://blog.csdn.net/FoxDave 在构建SPFx客户端web部件时,你可以使用公网已有的JavaScript库来构建强大的解决方案。但是在使用的时候你需要考虑你引用的东西没有影响SharePoint页面的性能。 以包的形式引用已存在的库 引用已存在的JavaScript库的通常方式是以包的形式安装到项目中。拿Angular举例,首先在项目中安装它的包: npm install angular --save 接下来通过TypeScript使用Angular,需要安装类型: npm install @types/angular --save 最后,在你的web部件中引用Angular,使用import声明: import { Version } from '@microsoft/sp-core-library';import { BaseClientSideWebPart, IPropertyPaneConfiguration, PropertyPaneTextField} from '@microsoft/sp-webpart-base';import { escape } from '@microsoft/sp-lodash-subset'; import styles from './HelloWorld.module.scss';import * as strings from 'helloWorldStrings';import { IHelloWorldWebPartProps } from './IHelloWorldWebPartProps'; import * as angular from 'angular'; export default class HelloWorldWebPart extends BaseClientSideWebPart { public render(): void { this.domElement.innerHTML = ` <div class="${styles.helloWorld}"> <!-- omitted for brevity --> </div>`; angular.module('helloworld', []); angular.bootstrap(this.domElement, ['helloworld']); } // omitted for brevity} 打包web部件资源 SPFx使用基于开源的工具链进行编译,如gulp和Webpack。在编译SPFx项目时,这些编译工具会在一个叫做bundling的进程中自动将所有引用的资源打包到一个单一的JavaScript文件中。这种方式有很多优点。首先,所有web部件需要的资源都在一个单一的JavaScript文件中可用。这简化了web部件的部署步骤,不容易产生遗漏。由于你的web部件使用了不同的资源,以正确的顺序逐个加载是很重要的。同时这种方式也对终端用户有益。一般来说,下载一个较大的单一文件要比下载好多小文件要快,进而你的web部件也会在页面上更快地完成加载。 然而这种方式也有一些不足。在编译SPFx中已存在的JavaScript框架时,所有引用的脚本都被包含在生成的单一文件中,以Angular为例,这个生成后的文件有170KB。 如果你在项目中再添加一个也使用Angular的web部件,在编译后你会发现有两个170KB的文件。这样当你在页面中同时添加这两个web部件的时候,就会加载两次同样内容的较大的脚本文件,这严重影响了性能。 作为外部资源引用已存在的库 一个更好的引用已存在的库的实现方式是作为外部资源进行引用。这样在web部件中就只有一个脚本的URL就够了,其实跟web页面的编写是一个意思,在页面加载的时候会自动去加载指定URL的资源。 这种方式也不需要进行包的安装,但是需要安装类型: npm install @types/angular --save 接下来在config/config.json文件中的externals属性中加入一条: "angular": { "path": "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js", "globalName": "angular"}完整的文件内容大致如下所示:{ "entries": [ { "entry": "./lib/webparts/helloWorld/HelloWorldWebPart.js", "manifest": "./src/webparts/helloWorld/HelloWorldWebPart.manifest.json", "outputPath": "./dist/hello-world.bundle.js" } ], "externals": { "angular": { "path": "https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular.min.js", "globalName": "angular" } }, "localizedResources": { "helloWorldStrings": "webparts/helloWorld/loc/{locale}.js" }}最后,在你的web部件中引用Angular就可以了,跟之前没什么区别: import { Version } from '@microsoft/sp-core-library';import { BaseClientSideWebPart, IPropertyPaneConfiguration, PropertyPaneTextField} from '@microsoft/sp-webpart-base';import { escape } from '@microsoft/sp-lodash-subset'; import styles from './HelloWorld.module.scss';import * as strings from 'helloWorldStrings';import { IHelloWorldWebPartProps } from './IHelloWorldWebPartProps'; import * as angular from 'angular'; export default class HelloWorldWebPart extends BaseClientSideWebPart { public render(): void { this.domElement.innerHTML = ` <div class="${styles.helloWorld}"> <!-- omitted for brevity --> </div>`; angular.module('helloworld', []); angular.bootstrap(this.domElement, ['helloworld']); } // omitted for brevity}再次编译你的项目你会发现这次的大小只有6KB。 如果你再添加一个web部件,那么就会生成两个大小为6KB的文件。说到这里大家可能会有疑问,这实际上就是大小变了而已,但是并没改变加载文件的数量。其实不是的,前一种方式是将要引用的库一起打包到了JS文件中,实际上相当于加载了两次;而对于外部引用这种方式,外部的资源如Angular只加载一次,并且得益于缓存机制,外部引用的资源很可能已经在用户访问你的web部件时加载好了,这么看确实是提高了性能。

资源下载

更多资源
腾讯云软件源

腾讯云软件源

为解决软件依赖安装时官方源访问速度慢的问题,腾讯云为一些软件搭建了缓存服务。您可以通过使用腾讯云软件源站来提升依赖包的安装速度。为了方便用户自由搭建服务架构,目前腾讯云软件源站支持公网访问和内网访问。

Spring

Spring

Spring框架(Spring Framework)是由Rod Johnson于2002年提出的开源Java企业级应用框架,旨在通过使用JavaBean替代传统EJB实现方式降低企业级编程开发的复杂性。该框架基于简单性、可测试性和松耦合性设计理念,提供核心容器、应用上下文、数据访问集成等模块,支持整合Hibernate、Struts等第三方框架,其适用范围不仅限于服务器端开发,绝大多数Java应用均可从中受益。

优质分享App

优质分享App

近一个月的开发和优化,本站点的第一个app全新上线。该app采用极致压缩,本体才4.36MB。系统里面做了大量数据访问、缓存优化。方便用户在手机上查看文章。后续会推出HarmonyOS的适配版本。

Sublime Text

Sublime Text

Sublime Text具有漂亮的用户界面和强大的功能,例如代码缩略图,Python的插件,代码段等。还可自定义键绑定,菜单和工具栏。Sublime Text 的主要功能包括:拼写检查,书签,完整的 Python API , Goto 功能,即时项目切换,多选择,多窗口等等。Sublime Text 是一个跨平台的编辑器,同时支持Windows、Linux、Mac OS X等操作系统。

用户登录
用户注册