2019/06/19
先分享一种密码加密方式;
Spring Security 提供了
BCryptPasswordEncoder类,
实现Spring的PasswordEncoder接口使用BCrypt强哈希方法来加密密码。
BCrypt强哈希方法 每次加密的结果都不一样。
除了加密以外还能比较密码
加密: BCryptPasswordEncoder encode = new BCryptPasswordEncoder(); encode.encode(password); 判断: 需要通过自带的方法 matches 将未经过加密的密码和已经过加密的密码传进去进行判断,返回布尔值。 encode.matches(oldpassword,user1.getPassword());
下面再看Ajax请求问题
post方式是由无限制的,而url是有限制的,那么就将url与传递的参数分开。
第一种方法 使用原生态的aiax的post
//创建请求 var xmlhttp; if (window.XMLHttpRequest) {// code for IE7+, Firefox, Chrome, Opera, Safari xmlhttp = new XMLHttpRequest(); } else {// code for IE6, IE5 xmlhttp = new ActiveXObject("Microsoft.XMLHTTP"); } //指定链接和参数 xmlhttp.open("POST", "/DLWeb/api/WbsNode/EditPMLog?", false); xmlhttp.setRequestHeader("Content-type", "application/x-www-form-urlencoded");//指定header xmlhttp.send(par); //响应请求 xmlhttp.onreadystatechange = function () { if (xmlhttp.readyState == 4 && xmlhttp.status == 200) {//成功 if (xmlhttp.responseText == "true") { alert("成功"); } else {//失败 alert("失败"); } } }
第二种方法 使用 ajax简化版请求方式
$.post or $.get
格式为
$.请求方式(请求地址,数据,成功回调方法);
请求地址不能省略,其他两个都可以省略,按照自己需求写。
Ajax 请求参数过多导致 400 错误 and BCryptPasswordEncoder 加密判断
原文:https://www.cnblogs.com/c-c-c-c/p/11049685.html