404 Not Found

Personal Notes


  • 首页

  • 归档

  • 标签

  • 搜索

Web 安全初探

发表于 May 26 2019

XSS(Cross Site Script,跨站脚本攻击)长期以来被列为客户端 Web 安全中的头号大敌,其本质就是一种「HTML 注入」,最简单的攻击场景就是:某网站有没有输入校验的输入框,而且不加处理地直接在页面上展示用户的输入内容,这样攻击者就可以输入一段 JavaScript 代码,浏览器展示用户输入内容的时候就会执行这段代码。

阅读全文 »

Spring 初探

发表于 May 19 2019

Spring 是于 2003 年兴起的一个轻量级的 Java 开发框架,如今已经发展成为事实上的业界标准,它有两个核心的理念:IoC 和 AOP,我想写几篇文章来分析一下这两个理念以及它们在 Spring 中的具体实现细节,这篇文章先用一段简单的程序来体验一下。

下面程序的 main() 方法中,首先根据配置文件 web-context.xml 创建了一个 IoC 容器,然后从容器中取出一个叫做 testController 的 bean,并调用这个 bean 的 sayHello() 方法,最后得到了两行输出。

public class Test {
public static void main(String[] args) {
ApplicationContext context = new ClassPathXmlApplicationContext("web-context.xml");
TestController controller = (TestController) context.getBean("testController");
controller.sayHello();
}
}

// TestAspect.doBefore()
// TestServiceImpl.sayHello()
阅读全文 »

MySQL 排序

发表于 May 3 2019

开发中经常会遇到根据指定字段排序的需求,通常使用 order by 实现,这篇文章结合极客时间专栏《MySQL 实战 45 讲》中相关的几讲,聊聊 order by 的执行过程。

CREATE TABLE person (
`id` BIGINT NOT NULL AUTO_INCREMENT,
`name` VARCHAR(32) NOT NULL,
`age` INT NOT NULL,
`city` VARCHAR(32) NOT NULL,
PRIMARY KEY (`id`)
KEY `city` (`city`)
) ENGINE=InnoDB;

INSERT INTO person (name, age, city) VALUES ('Alice', 14, 'Beijing'), ('Bob', 15, 'Beijing'), ('Eve', 9, 'Shanghai');

首先创建表 person 并插入三行数据,后面的测试都在这张表上进行。

阅读全文 »

MySQL 连接

发表于 May 3 2019

这篇文章还是学习极客时间专栏《MySQL实战 45 讲》的笔记,我们都听说过 JOIN 可能是个十分消耗资源的操作,《阿里巴巴 JAVA 开发手册》中也禁止 JOIN 三张以上的表,那究竟为什么 JOIN 操作让人如此「恐惧」呢?下面结合专栏中关于 JOIN 的几讲,聊聊 JOIN 的执行过程以及优化方法。

create table `t2` (
`id` int(11) not null,
`a` int(11) default null,
`b` int(11) default null,
primary key (`id`),
key `a` (`a`)
) engine=innodb;

drop procedure if exists idata;
delimiter ;;
create procedure idata()
begin
declare i int;
set i = 1;
while ( i <= 1000) do
insert into t2 values (i, i, i);
set i = i + 1;
end while;
end;;
delimiter ;
call idata();

create table t1 like t2;
insert into t1 (select * from t2 where id <= 100);

上面的 SQL 语句是直接从专栏中复制的:首先创建了表 t2,其中 a 字段上面有索引,然后使用存储过程插入 1000 行数据;创建结构相同的表 t1,将 t2 的前 100 行数据插入 t1。

阅读全文 »

MySQL 索引

发表于 Apr 21 2019

在 MySQL 中,索引是在存储引擎层而不是 Server 层实现的,所以没有统一的索引标准:不同存储引擎的索引的工作方式并不一样,也不是所有的存储引擎都支持所有类型的索引。即使多个存储引擎支持同一种类型的索引,其底层的实现也可能不同。MySQL 支持的索引类型有 B-Tree 索引、哈希索引、全文索引等,默认的 InnoDB 存储引擎实现的是 B-Tree 索引。

阅读全文 »

1…345…9
wind4869

wind4869

44 日志
12 标签
GitHub E-Mail
© 2014 - 2020 wind4869
由 Hexo 强力驱动
主题 - NexT.Pisces
0%