vpn mysql_MYSQL数据库

1.关系型数据库相关概念

关系Relational :关系就是二维表,其中:表中的行、列次序并不重要

行row:表中的每一行,又称为一条记录record

列column:表中的每一列,称为属性,字段,域field

主键Primary key:PK ,一个或多个字段的组合, 用于惟一确定一个记录的字段,一张表只有一个主 键, 主键字段不能为空NULL

唯一键Unique key: 一个或多个字段的组合,用于惟一确定一个记录的字段,一张表可以有多个UK,而 且UK字段可以为NULL

域domain:属性的取值范围,如,性别只能是'男'和'女'两个值,人类的年龄只能0-150

2.常用关系数据库

MySQL: MySQL, MariaDB, Percona Server

PostgreSQL: 简称为pgsql,EnterpriseDB

Oracle

MSSQL Server

DB2

3联系类型

一对一联系(1:1)

一对多联系(1:n):外键

多对多联系(m:n):增加第三张表3联系类型

4.数据库规划流程

1. 收集数据,得到字段 收集必要且完整的数据项 转换成数据表的字段

2. 把字段分类,归入表,建立表的关联 关联:表和表间的关系 分割数据表并建立关联的优点 节省空间 减少输入错误 方便数据修改

3. 规范化数据库

5.数据库的正规化

在第一范式的基础上进一步满足更多规范要求的称为第二范式(2NF),其余范式以次类 推。一般数据库只需满足第三范式(3NF)即可 规则是死的,人是活的,所以范式是否必须遵守,要看业务需要而定 掌握范式的目的是为了在合适的场景下违反范式

第一范式:1NF

无重复的列,每一列都是不可分割的基本数据项,同一列中不能有多个值,即实体中的某个属性不能有 多个值或者不能有重复的属性,确保每一列的原子性。除去同类型的字段,就是无重复的列 说明:第一范式(1NF)是对关系模式的基本要求,不满足第一范式(1NF)的数据库就不是关系数据 库

第二范例:2NF

第二范式必须先满足第一范式,属性完全依赖于主键,要求表中的每个行必须可以被唯一地区分,通常 为表加上每行的唯一标识PK,非PK的字段需要与整个PK有直接相关性,即非PK的字段不能依赖于部分主键

第三范式:3NF

满足第三范式必须先满足第二范式属性,非主键属性不依赖于其它非主键属性。第三范式要求一个数据 表中不包含已在其它表中已包含的非主关键字信息,非PK的字段间不能有从属关系

6.MySQL安装方式介绍和快速安装

安装方式

程序包管理器管理的程序包

源代码编译安装

二进制格式的程序包:展开至特定路径,并经过简单配置后即可使用

centos8:安装光盘直接提供

mysql-server:8.0

mariadb-server:10.3.17

centos7:安装光盘直接提供

mariadb-server:5.5 服务包

mariadb 客户端工具包

centos6:

mysql-serve:5.1 服务器包

mysql 客户端工具包

范例

[14:07:38 root@centos7 yum.repos.d]$vim mysql.repo 创建仓库

[mysql]

name=mysql5.7baseurl=https://mirrors.tuna.tsinghua.edu.cn/mysql/yum/mysql-5.7-community-el7-x86_64/

gpgcheck=0配置清华大学仓库路径

[14:10:44 root@centos7 yum.repos.d]$yum list |grep 'mysql*'可以看到包

[14:10:44 root@centos7 yum.repos.d]$yum -y install mysql-community-server

[14:19:40 root@centos7 yum.repos.d]$systemctl enable --now mysqld

ss-ntl 发现端口3306开启

[14:22:34 root@centos7 yum.repos.d]$mysql 5.7版本会默认创建数据库用户root'@'localhost

ERROR1045 (28000): Access denied for user 'root'@'localhost'(using password: NO)

[14:27:43 root@centos7 yum.repos.d]$grep password /var/log/mysqld.log 临时密码位置2021-01-28T06:20:26.300014Z 1 [Note] A temporary password is generated for root@localhost: AK:1dY&92qyb2021-01-28T06:21:55.139910Z 2 [Note] Access denied for user 'root'@'localhost'(using password: NO)2021-01-28T06:22:45.441398Z 3 [Note] Access denied for user 'root'@'localhost'(using password: NO)

[14:28:11 root@centos7 yum.repos.d]$mysql -uroot -p'AK:1dY&92qyb'初始密码登录后会要求你修改密码

mysql: [Warning] Using a password on the command line interface can be insecure.

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 4Server version:5.7.33Copyright (c)2000, 2021, Oracle and/or its affiliates.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

mysql> ALTER USER root@'localhost' identified by 'Yangbo!0'; 注意密码要设置的复杂一些

Query OK,0 rows affected (0.00sec)

mysql>status--------------mysql Ver14.14 Distrib 5.7.33, forLinux (x86_64) using EditLine wrapper

Connectionid: 5Current database:

Current user: root@localhost

SSL: Notinuse

Current pager: stdout

Using outfile:''Using delimiter: ;

Server version:5.7.33Protocol version:10Connection: Localhost via UNIX socket

Server characterset: latin1

Db characterset: latin1

Client characterset: utf8

Conn. characterset: utf8

UNIX socket:/var/lib/mysql/mysql.sock

Uptime:24 min 13sec

Threads:1 Questions: 22 Slow queries: 0 Opens: 107 Flush tables: 1 Open tables: 100 Queries per second avg: 0.015

--------------mysql>exit

修改初始密码吗方法二

[14:45:28 root@centos7 yum.repos.d]$mysqladmin -uroot -p'AK:1dY&92qyb' password 'Yangbo!0'

Ubuntu默认启用,空密码登录

7初始化脚本提高安全性

运行脚本:mysql_secure_installation

设置数据库管理员root口令

禁止root远程登录

删除anonymous用户帐号

删除test数据库

范例:针对5.6版本安全加固

[15:06:20 root@centos7 yum.repos.d]$mysql

Welcome to the MySQL monitor. Commands end with ; or \g.

Your MySQL connectionid is 3Server version:5.6.51MySQL Community Server (GPL)

Copyright (c)2000, 2021, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its

affiliates. Other names may be trademarks of their respective

owners.

Type'help;' or '\h' for help. Type '\c' to clearthe current input statement.

默认空密码登录

mysql> selectuser,host from mysql.user;+------+-----------+

| user | host |

+------+-----------+

| root | 127.0.0.1 |

| root | ::1 |

| | centos7 |

| root | centos7 |

| | localhost |匿名账号| root | localhost |

+------+-----------+

6 rows in set (0.00sec)

代表6个用户

[15:12:11 root@centos7 yum.repos.d]$mysql_secure_installation

NOTE: RUNNING ALL PARTS OF THIS SCRIPT IS RECOMMENDED FOR ALL MySQL

SERVERS IN PRODUCTION USE! PLEASE READ EACH STEP CAREFULLY!In order to log into MySQL to secure it, we'll need the current

password for the root user. If you've just installed MySQL, and

you haven't set the root password yet, the password will be blank,

so you should just press enter here.

Enter current passwordfor root (enter fornone): 没有密码回车

OK, successfully used password, moving on...

Setting the root password ensures that nobody can log into the MySQL

root user without the proper authorisation.

Set root password? [Y/n] y 是否设置root口令

New password:

Re-enter new password:

Password updated successfully!Reloading privilege tables..

... Success!By default, a MySQL installation has an anonymous user, allowing anyone

to log into MySQL without having to have a user account createdforthem. This is intended onlyfor testing, and to makethe installation

go a bit smoother. You should remove them before moving into a

production environment.

Remove anonymous users? [Y/n] y 是否移除匿名用户

... Success!Normally, root should only be allowed to connect from'localhost'. This

ensures that someone cannot guess at the root password from the network.

Disallow rootlogin remotely? [Y/n] y 禁用远程登录

... Success!By default, MySQL comes with a database named'test'that anyone can

access. This is also intended onlyfortesting, and should be removed

before moving into a production environment.

Remove test database and access to it? [Y/n] y-Dropping test database...

ERROR1008 (HY000) at line 1: Can't drop database'test'; database doesn't exist

... Failed!Not critical, keep moving...-Removing privileges on test database...

... Success!Reloading the privilege tables will ensure that all changes made so far

will take effect immediately.

Reload privilege tables now? [Y/n] y 是否生效

... Success!Alldone! If you've completed all of the above steps, your MySQL

installation should now be secure.

Thanksfor using MySQL!Cleaning up...

[15:18:19 root@centos7 yum.repos.d]$mysql

ERROR1045 (28000): Access denied for user 'root'@'localhost'(using password: NO)

再次空口令登录失败

[15:17:56 root@centos7 yum.repos.d]$mysql -uroot -p'123456'登录成功

mysql> selectuser,host from mysql.user;+------+-----------+

| user | host |

+------+-----------+

| root | 127.0.0.1 |

| root | ::1 |

| root | localhost |

+------+-----------+

3 rows in set (0.00sec)

删除了之前的不安全登录

8.MYSQL组成

客户端程序

mysql: 交互式或非交互式的CLI工具

mysqldump:备份工具,基于mysql协议向mysqld发起查询请求,并将查得的所有数据转换成

insert等写操作语句保存文本文件中

mysqladmin:基于mysql协议管理mysqld

[15:35:39 root@centos7 yum.repos.d]$mysqladmin -uroot -p'Yangbo!0'用法帮助ping[15:29:05 root@centos7 yum.repos.d]$mysqladmin -uroot -p'Yangbo!0' pingmysqladmin: [Warning] Using a password on the command line interface can be insecure.

mysqld is alive

验证数据库是否正常运行

shutdown

[15:29:05 root@centos7 yum.repos.d]$mysqladmin -uroot -p'Yangbo!0'shutdown

安全的关闭数据库,要耐心等待

mysqlimport:数据导入工具

服务器端程序

mysqld_safe

mysqld

mysqld_multi 多实例 ,示例:mysqld_multi --example

用户账户

mysql用户账号由两部分组成:

'USERNAME'@'HOST'

说明: HOST限制此用户可通过哪些远程主机连接mysql服务器 支持使用通配符:

% 匹配任意长度的任意字符,相当于shell中*, 示例: 172.16.0.0/255.255.0.0 或 172.16.%.%_ 匹配任意单个字符

9.mysql 客户端命令

客户端命令:本地执行,每个命令都完整形式和简写格式

mysql>\h, help

mysql>\u,use

mysql>\s,status

mysql> \!,system

服务端命令:通过mysql协议发往服务器执行并取回结果,命令末尾都必须使用命令结束符号,默 认为分号

-A, --no-auto-rehash 禁止补全-u, --user=用户名,默认为root-h, --host=服务器主机,默认为localhost-p, --passowrd= 用户密码,建议使用-p,默认为空密码-P, --port=服务器端口-S, --socket=指定连接socket文件路径-D, --database=指定默认数据库-C, --compress 启用压缩-e “SQL“ 执行SQL命令-V, --version 显示版本-v --verbose 显示详细信息--print-defaults 获取程序默认使用的配置

范例:mysql的配置文件,修改提示符

[16:15:51 root@centos7 yum.repos.d]$mysql -uroot -p'Yangbo!0' --prompt="(\\u@\\h) [\\d]>\\_"临时修改mysql提示符

[16:17:49 root@centos7 ~]$vim /etc/my.cnf

[mysql]

prompt="\\r:\\m:\\s(\\u@\\h) [\\d]>\\_"写入配置文件永久保存

范例:配置所有MySQL客户端的自动登录

[16:17:49 root@centos7 ~]$vim /etc/my.cnf

[mysql]

user=root

password='Yangbo!0'

服务器端配置

服务器端配置文件:

/etc/my.cnf #Global选项

/etc/mysql/my.cnf #Global选项

~/.my.cnf #User-specific 选项

配置文件格式:

[mysqld]

[mysqld_safe]

[mysqld_multi]

[mysql]

[mysqldump]

[server]

[client]

格式:

parameter = value

socket地址

ip socket: 监听在tcp的3306端口,支持远程通信 ,侦听3306/tcp端口可以在绑定有一个或全部接 口IP上 unix sock: 监听在sock文件上,仅支持本机通信, 如:/var/lib/mysql/mysql.sock

范例:关闭远程连接,通过socket文件连接

vim /etc/my.cnf

[mysqld]

skip-networking=1

10.通用二进制格式安装MySQL 5.7

安装相关包

[16:45:03 root@centos7 ~]$yum -y install libaio numactl-libs

用户和组

[16:45:03 root@centos7 ~]$groupadd mysql

[16:45:43 root@centos7 ~]$useradd -r -g mysql -s /bin/false mysql

准备程序文件

[16:54:22 root@centos7 ~]$wget http://mirrors.163.com/mysql/Downloads/MySQL-5.7/mysql-5.7.31-linux-glibc2.12

[16:58:44 root@centos7 ~]$tar xf mysql-5.7.31-linux-glibc2.12-x86_64.tar.gz -C /usr/local/[16:59:46 root@centos7 ~]$cd /usr/local/[16:59:56 root@centos7 local]$ln -s mysql-5.7.31-linux-glibc2.12-x86_64/mysql

[17:03:30 root@centos7 local]$chown -R root:root /usr/local/mysql/

准备环境变量

[17:05:43 root@centos7 local]$echo 'PATH=/usr/local/mysql/bin:$PATH' > /etc/profile.d/mysql.sh[17:09:09 root@centos7 local]$. /etc/profile.d/mysql.sh

准备配置文件

[17:13:41 root@centos7 local]$cp /etc/my.cnf{,.bak} 备份原文件

[17:14:31 root@centos7 local]$vim /etc/my.cnf

[mysqld]

datadir=/data/mysql

skip_name_resolve=1socket=/data/mysql/mysql.sock

log-error=/data/mysql/mysql.log

pid-file=/data/mysql/mysql.pid

[client]

socket=/data/mysql/mysql.sock

生成数据库文件,并提取root密码

[17:46:49 root@centos7 /]$mkdirdata

[17:47:00 root@centos7 /]$mysqld --initialize --user=mysql --datadir=/data/mysql5.6版本生成数据库/usr/local/mysql/scripts/mysql_install_db --user=mysql -- datadir=/data/mysql --basedir=/usr/local/mysql/[17:48:51 root@centos7 /]$grep password /data/mysql/mysql.log2021-01-28T09:47:16.362119Z 1 [Note] A temporary password is generated for root@localhost: R&d0iVsQ,564初始密码

[17:53:37 root@centos7 /]$awk '/temporary password/{print $11}' /data/mysql/mysql.log

R&d0iVsQ,564

准备服务脚本和启动

[17:53:54 root@centos7 /]$cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld

[18:01:31 root@centos7 /]$chkconfig --add mysqld

[18:01:40 root@centos7 /]$service mysqld start

修改口令

[18:01:51 root@centos7 /]$mysqladmin -uroot -p'R&d0iVsQ,564'password yangbo

[18:05:06 root@centos7 /]$mysql -uroot -p'yangbo'登录成功

11.源码编译安装mysql-5.6.51

安装相关依赖包

yum -y install gcc gcc-c++ cmake bison bison-devel zlib-devel libcurl-devel libarchive-devel boost-devel ncurses-devel gnutls-devel libxml2-devel openssl-devel libevent-devel libaio-devel perl-Data-Dumper

准备用户和数据目录

useradd -r -s /sbin/nologin -d /data/mysql mysql

准备用户和数据目录

[18:25:56 root@centos7 ~]$mkdir -p /data/mysql

[18:26:24 root@centos7 data]$chown mysql:mysql /data/mysql

下载源码包并解压缩源码包

[18:21:06 root@centos7 ~]$tar -xf mysql-5.6.51.tar.gz -C /usr/local/src

[18:27:03 root@centos7 data]$cd /usr/local/src/mysql-5.6.51/[18:52:44 root@centos7 mysql-5.6.51]$cmake . \-DCMAKE_INSTALL_PREFIX=/apps/mysql \-DMYSQL_DATADIR=/data/mysql/\-DSYSCONFDIR=/etc/\-DMYSQL_USER=mysql \-DWITH_INNOBASE_STORAGE_ENGINE=1\-DWITH_ARCHIVE_STORAGE_ENGINE=1\-DWITH_BLACKHOLE_STORAGE_ENGINE=1\-DWITH_PARTITION_STORAGE_ENGINE=1\-DWITHOUT_MROONGA_STORAGE_ENGINE=1\-DWITH_DEBUG=0\-DWITH_READLINE=1\-DWITH_SSL=system \-DWITH_ZLIB=system \-DWITH_LIBWRAP=0\-DENABLED_LOCAL_INFILE=1\-DMYSQL_UNIX_ADDR=/data/mysql/mysql.sock \-DDEFAULT_CHARSET=utf8 \-DDEFAULT_COLLATION=utf8_general_ci

[18:52:44 root@centos7 mysql-5.6.51]$make && make install如果出错rm-rf CMakeCache.txt

准备环境变量

[18:52:44 root@centos7 mysql-5.6.51]$echo 'PATH=/apps/mysql/bin:$PATH' > /etc/profile.d/mysql.sh[18:59:11 root@centos7 mysql-5.6.51]$. /etc/profile.d/mysql.sh

生成数据库文件

[18:59:33 root@centos7 mysql-5.6.51]$cd /apps/mysql/[19:01:20 root@centos7 mysql]$scripts/mysql_install_db --datadir=/data/mysql/ --user=mysql

准备配置文件

[19:01:20 root@centos7 mysql]$cp -b /apps/mysql/support-files/my-default.cnf /etc/my.cnfcp: overwrite ‘/etc/my.cnf’? y

准备启动脚本,并启动服务

[19:03:28 root@centos7 mysql]$cp /apps/mysql/support-files/mysql.server /etc/init.d/mysqld

[19:09:23 root@centos7 mysql]$chkconfig --add mysqld

[19:09:32 root@centos7 mysql]$service mysqld start

安全初始化

mysql_secure_installation

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/327859.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

Stateless 3.0——.NET Core上的状态机库

Stateless是一个基于C#,创建状态机的简单库,最新版本支持.NET Core 1.0。其实现方式并不是通过.NET Core,而是通过写入.NET Standard实现的。就像Android平台上API级别抽象出许多底层版本的Android,.NET Standard是一组所有.NET平…

Java压缩技术(五) GZIP相关——浏览器解析

转载自 Java压缩技术(五) GZIP相关——浏览器解析 GZIP本身就是一种网络流压缩算法,而且应用相当广泛。如果网络访问过程中,其数据流较大,势必降低网络访问效率,此时就需要考虑使用压缩!当然&…

在实际使用中 mysql所支持的触发器有_2016计算机二级MySQL冲刺题及答案

2016计算机二级MySQL冲刺题及答案11[简答题] 请使用UPDATE语句将数据库db_test的表content中留言人姓名为“MySQL初学者”的留言内容修改为“如何使用INSERT语句?”。参考解析:在MySQL命令行客户端输入如下SQL语句即可实现:mysql>USE db-test;Databa…

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c

[Err] 1055 - Expression #1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated c 解决MySQL报错:1 of ORDER BY clause is not in GROUP BY clause and contains nonaggregated column informat [Err] 1055 - Expression #1 of ORDER BY …

在mysql中插入日期

preparedStatement.setDate(5,new Date(new java.util.Date().getTime()));//给第五个占位符? 的值赋值为new Date(new java.util.Date().getTime()); 外面的Date是SQL中的java.sql.*; 里面的Date是java中的java.util.Date;

Hibernate中使用Criteria查询及注解——(HibernateUtil)

HibernateUtil hibernate工具类: package cn.bdqn.hibernate_Criteria.Util;import org.hibernate.Session; import org.hibernate.cfg.Configuration;public class HibernateUtil {private static Session session; …

进程管理supervisor的简单说明

背景: 项目中遇到有些脚本需要通过后台进程运行,保证不被异常中断,之前都是通过nohup、&、screen来实现,带着能否做一个start/stop/restart/reload的服务启动的想法找到里Supervisor。关于supervisor的介绍在网上大致搜索总结…

Java压缩技术(四) GZIP——Java原生实现

转载自 Java压缩技术(四) GZIP——Java原生实现 GZIP常常用在linxu环境下,是一种非常简单的压缩算法。在Java实现API中,它仅仅包含两个实现类:GZIPInputStream和GZIPOutputStream。 GZIPOutputStream类用于压缩 GZIPI…

数据结构树的基本操作_树的各类基本操作(数据结构)

#include "iostream"/*输入:ABC DE G FABC DE G F*/#include "bits/stdc.h"using namespace std;typedef struct bitnode{char data;bitnode *lchild,*rchild;} *bintree;bintree creatree(bintree &root)//先序创建树{char agetchar();if(…

下载bilibli网站视频

https://www.videofk.com/bilibili-video-download/ bilibili https://www.videofk.com/bilibili-video-download/search?urlhttps%3A%2F%2Fwww.bilibili.com%2Fvideo%2Fav50186988&selectbilibili

处理js乱码

1.将time.js编码格式更改外 2.在Tomcat设置VM-OPTION 选项为-Dfile.encodingutf-8

asp.net core 实战之 redis 负载均衡和quot;高可用quot;实现

1.概述 分布式系统缓存已经变得不可或缺,本文主要阐述如何实现redis主从复制集群的负载均衡,以及 redis的"高可用"实现, 呵呵双引号的"高可用"并不是传统意义的高可用哈,而是 redis集群挂了,并不影响asp.net core 的运行, 欲知详情,请看下文. 注意: 本文主…

Java IO: 其他字符流(下)

转载自 Java IO: 其他字符流(下)作者: Jakob Jenkov 译者: 李璟(jlee381344197gmail.com) 本小节会简要概括Java IO中的PushbackReader,LineNumberReader,StreamTokenizer,PrintWriter,StringReader,StringWriter。P…

java 长字符串 比较_Java字符串比较(3种方法)

字符串比较是常见的操作,包括比较相等、比较大小、比较前缀和后缀串等。在 Java 中,比较字符串的常用方法有 3 个:equals() 方法、equalsIgnoreCase() 方法、 compareTo() 方法。下面详细介绍这 3 个方法的使用。equals() 方法equals() 方法将…

IntelliJ IDEA 项目结构旁边出现 0%methods,0% lines covered 解决

IntelliJ IDEA 项目结构旁边出现 0%methods,0% lines covered 解决 windows 1.选中根目录文件夹 ctrl alt f6弹出如下框,取消勾选-->点击Show Selected就可以去掉了 mac 1.选中根目录文件夹 option fn command f6弹出如下框,取消勾选-->点击Show Select…

javaweb---简易邮件发送

邮件发送 2.jar包的支持 activation-1.1.1.jar mail-1.4.7.jar 3.授权码的获取 4.简易文本邮件发送的实现 由上图我们可以确定几个必须步骤 1.创建session对象 2.创建Transport对象 3.使用邮箱的用户名和授权码连上邮件服务器 4.创建一个Message对象(需要传递…

Hibernate中使用Criteria查询及注解——(DeptTest.java)

DeptTest.java 测试类: 先创建Session: private Session session;private Transaction tx;Beforepublic void beforeMethod(){sessionnew Configuration().configure().buildSessionFactory().openSession();}关闭Session: Afterpublic void…

asp.net core 负载均衡集群搭建(centos7+nginx+supervisor+kestrel)

概述 本文目的是搭建三台asp.net core 集群, 并配上 nginx做负载均衡 首先准备要运行的源码 http://pan.baidu.com/s/1c20x0bA 准备三台服务器(或则虚拟机) 192.168.182.129 , 192.168.182.130 , 192.168.182.131 并将源码发布至三台服务器的 /root/aspnetcore/anuoapc 目录 …

Java IO教程

转载自 Java IO教程译文链接 作者:Jakob Jenkov 译者:Connor (cronnorcgmail.com) ,李璟 校对:方腾飞 Java IO 是一套Java用来读写数据(输入和输出)的API。大部分程序都要处理一些输入,并由输…

Java web登录拦截器_SpringMVC拦截器(实现登录验证拦截器)

本例实现登陆时的验证拦截,采用SpringMVC拦截器来实现核心代码首先是index.jsp,显示链接String path request.getContextPath();String basePath request.getScheme()"://"request.getServerName()":"request.getServerPort()path"/&quo…