当前位置: 首页 > news >正文

电气网站建设百度快速seo

电气网站建设,百度快速seo,中国最大的软件外包公司,怎么看公司网站做的好不好哦Element UI框架学习篇(三) 实现简单登录功能(不含记住密码) 1 准备工作 1.1 在zlz包下创建dto包,并创建userDTO类(传输对象) package com.zlz.dto;import lombok.Data;/* DTO 数据传输对象 用户表的传输对象 调用控制器传参使用 VO 控制器返回的视图对象 与页面对应 PO 数据…

Element UI框架学习篇(三)

实现简单登录功能(不含记住密码)

1 准备工作

1.1 在zlz包下创建dto包,并创建userDTO类(传输对象)

package com.zlz.dto;import lombok.Data;/*
DTO 数据传输对象 用户表的传输对象 调用控制器传参使用
VO 控制器返回的视图对象 与页面对应
PO 数据库持久对象 与数据库表对应*/
@Data
public class UsersDTO {//后台需要什么参数就写什么,不更数据库一样(隐藏数据库细节)private String yhm;private String pwd;private String jzw;
}

1.2 在util包下新建一个统一json返回格式的类Results

package com.zlz.util;import lombok.Data;/*** 统一json格式返回类*/
@Data
public class Results {private int code;//自定义状态码private String msg;//消息private Object data;//数据//无参构造一定要有public Results(){}public Results(int code, String msg) {this.code = code;this.msg = msg;}public Results(int code, String msg, Object data) {this.code = code;this.msg = msg;this.data = data;}public static Results ok(){//200是自定义的状态码return  new Results(200, "success");}public static Results ok(int code,String msg){//200是自定义的状态码return  new Results(code,msg);}//只传数据的public static Results ok(Object data){//200是自定义的状态码return  new Results(200,"success",data);}public static Results error(String msg){//500是自定义的状态码return  new Results(500,msg);}
}

1.3 在SysUserController类里面添加如下方法

@RequestMapping("ajaxlogin")
@ResponseBody
public Results ajaxlogin(@RequestBody UsersDTO user){Subject subject = SecurityUtils.getSubject();UsernamePasswordToken token=new UsernamePasswordToken(user.getYhm(),user.getPwd());try {subject.login(token);SysUser user1 = sysUserMapper.findUser(user.getYhm());return Results.ok(user1);}catch (UnknownAccountException exception){return Results.error("用户名不存在");}catch (LockedAccountException exception){return Results.error("账号已被锁定");}catch (Exception exception){return Results.error("密码错误");}
}

1.4 使用apipost软件测试后台地址是否能正常访问

1.4.1 注意点
测试时要在body-->raw里面输入json数据,因为是用requestBody去接收的
传入的参数的key必须和@RequestBody对应的实体类里面的参数保持一致,不然就传递不过去
1.4.2 当输入的用户名不存在时

052888888888888888.+-

1.4.3 当输入的用户名存在,但密码错误时

在这里插入图片描述

1.4.4 当输入的用户被锁定时

在这里插入图片描述

1.4.4 当输入的用户名和密码都完全正确时

在这里插入图片描述

2 实现登录界面的消息提示

2.1 登录界面login01.html

<!DOCTYPE html>
<html lang="en">
<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"><link rel="stylesheet" href="../elementUI/elementUI.min.css"><!-- 先导vue.js再导入elementUI --><script src="../js/vue.js"></script><script src="../js/axios.min.js"></script><script src="../elementUI/elementUI.min.js"></script><title>Document</title><style>#app{width: 300px;border-radius: 10px; /*圆角边框*/box-shadow: 0 0 3px gray; /*盒子阴影*/padding: 20px;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);}</style>
</head>
<body><div id="app"><h3 style="text-align: center;">用户登录</h3><!-- label-width为 el-form-item标签中中的label属性所占据宽度 --><!-- 这个user时和vue实例中的user是一一对应的 --><el-form :model="users" label-width="70px"><el-form-item label="用户名"><el-input v-model="users.yhm"></el-input></el-form-item><el-form-item label="密码"><!-- show-password显示明文密码 --><el-input v-model="users.pwd" show-password></el-input></el-form-item><el-form-item><!-- 函数先写 --><!-- style里面写width宽度 --><el-button @click="login" type="primary" style="width:240px">登录</el-button></el-form-item></el-form></div><script src="../js/login01.js"></script>
</body>
</html>

2.2 登录成功时跳转的主页代码

<!DOCTYPE html>
<html lang="en">
<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"><script src="../js/vue.js"></script><title>Document</title>
</head>
<body><h3>主页</h3><div id="app"><div v-if="users!=null">已登录你的用户名{{users.username}}</div><div v-else>未登录</div></div><script>new Vue({el:"#app",data:{users:null,},//页面一加载时,就会获取sessoin域中的内容,并把其在页面上显示出来mounted(){var str=sessionStorage.getItem("users");// 把json字符串转成Json对象this.users=JSON.parse(str);}})</script>
</body>
</html>

2.3 异步提交的逻辑代码login01.js

new Vue({el:"#app",data:{users:{// 页面需要什么 就写什么 要和dto对应yhm:null,pwd:null},},methods:{// 钩子函数自己运行的 生命周期自己运行的//.then正确回调login(){axios.post("http://127.0.0.1:8080/users/ajaxlogin",this.users).then(jg=>{var code=jg.data.code;if(code==500){//固定用法this.$message.error(jg.data.msg);}else{this.$message.success('登录成功');//存储用户在session里面console.log(jg);//data是Results对象,接收的是实体类user,所以取出可以用username//将对象转换成json类型的字符串var userJson=JSON.stringify(jg.data.data);//前台要json对象才行sessionStorage.setItem('users',userJson);setTimeout(function(){location="主页.html";},2000)}}).catch(jg=>{//服务器报错了这里this.$message.error("服务器错误:"+jg)})// alert测试是否进入方法}}
})

2.4 在SysUserController类上加上@CrossJoin注解,解决跨域问题

在这里插入图片描述

2.5 测试

2.5.1 当初次进入登录界面时

在这里插入图片描述

2.5.2 当用户名不存在时候

在这里插入图片描述

2.5.3 当用户名存在但密码错误时

在这里插入图片描述

2.5.4 当用户名被锁定时

在这里插入图片描述

2.5.5 当用户名和密码完全正确时
a 登录前

在这里插入图片描述

b 点击登录按钮时

在这里插入图片描述

c 点击登录按钮2秒钟后

在这里插入图片描述

3 实现登录页面的格式验证(非空验证加特定格式验证)

3.1 实现非空验证的思路

①在表单元素el-form表单上加上:rules="自定义规则名"
②在vue实例中的data里面自定义规则名(以json数组的格式)
如 自定义规则名
自定义规则名:{// 表单绑定对象要一样的表单绑定对象的属性名:[//验证规则 使用{}抱起来,下面这句话的意思是在失去焦点的时候进行非空验证,并给出提示信息——请输入用户名{required: true,message:"请输入用户名",trigger:"blur"}],
}
③ 在表单需要进行验证的字段上面加上prop="表单绑定对象的属性名"
<el-form-item label="密码" prop="pwd">

3.2 实现特定格式验证的思路

①在表单元素el-form表单上加上:rules="自定义规则名"
②在vue实例中的data里面自定义规则名(以json数组的格式)
如 自定义规则名
自定义规则名:{// 表单绑定对象要一样的表单绑定对象的属性名:[//验证规则 使用{}抱起来,下面这句话的意思是在失去焦点的时候字段长度验证,如果输入的密码不在2-10位之间,就会给出提示文字{min: 2,max:10,message:"密码长度必须在2-10位",trigger:"blur"}],
}
③ 在表单需要进行验证的字段上面加上prop="表单绑定对象的属性名"
<el-form-item label="密码" prop="pwd">

3.3 登录界面login02.html

<!DOCTYPE html>
<html lang="en">
<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"><link rel="stylesheet" href="../elementUI/elementUI.min.css"><!-- 先导vue.js再导入elementUI --><script src="../js/vue.js"></script><script src="../js/axios.min.js"></script><script src="../elementUI/elementUI.min.js"></script><title>Document</title><style>#app{width: 300px;border-radius: 10px; /*圆角边框*/box-shadow: 0 0 3px gray; /*盒子阴影*/padding: 20px;position: absolute;left: 50%;top: 50%;transform: translate(-50%,-50%);}</style>
</head>
<body><div id="app"><h3 style="text-align: center;">用户登录</h3><!-- label-width中午所占据宽度 --><!-- usersYz与js中验证 --><el-form :model="users" :rules="usersYz"  ref="myform" label-width="70px"><el-form-item label="用户名" prop="yhm"><el-input v-model="users.yhm"></el-input></el-form-item><el-form-item label="密码" prop="pwd"><!-- show-password显示明文密码 --><el-input v-model="users.pwd" show-password></el-input></el-form-item><el-form-item><!-- 函数先写 --><!-- style里面写width宽度 --><el-button @click="login" type="primary" style="width:240px">登录</el-button></el-form-item></el-form></div><script src="../js/login02.js"></script>
</body>
</html>

3.4 异步提交逻辑代码login02.js

new Vue({el:"#app",data:{users:{// 页面需要什么 就写什么 要和dto对应yhm:null,pwd:null},usersYz:{// 表单绑定对象要一样的yhm:[{required: true,message:"请输入用户名",trigger:"blur"}],pwd:[{required: true,message:"请输入密码",trigger:"blur"},{min: 2,max:10,message:"密码长度必须在2-10位",trigger:"blur"}]}},methods:{// 钩子函数自己运行的 生命周期自己运行的//.then正确回调login(){//保证表单提交的时候有作用 this.$refs['myform'].validatethis.$refs['myform'].validate((v) => {if(v){axios.post("http://127.0.0.1:8080/users/ajaxlogin",this.users).then(jg=>{var code=jg.data.code;if(code==500){//固定用法this.$message.error(jg.data.msg);}else{this.$message.success('登录成功');//存储用户在session里面console.log(jg);//data是Results对象,接收的是实体类user,所以取出可以用username//将对象转换成json类型的字符串var userJson=JSON.stringify(jg.data.data);//前台要json对象才行sessionStorage.setItem('users',userJson);setTimeout(function(){location="主页.html";},2)}}).catch(jg=>{//服务器报错了这里this.$message.error("服务器错误:"+jg)})}})// alert测试是否进入方法}}
})

3.5 测试

3.5.1 提交表单时,当用户填写的字段存在空值时

在这里插入图片描述

3.5.2 提交表单时,当用户填写的字段不符合自定义格式要求时

在这里插入图片描述


文章转载自:
http://beefy.xtqr.cn
http://attritus.xtqr.cn
http://sthenic.xtqr.cn
http://lob.xtqr.cn
http://quant.xtqr.cn
http://missileman.xtqr.cn
http://unclench.xtqr.cn
http://negativity.xtqr.cn
http://stabbing.xtqr.cn
http://storehouse.xtqr.cn
http://ligamentous.xtqr.cn
http://autohypnotism.xtqr.cn
http://haematemesis.xtqr.cn
http://mucronate.xtqr.cn
http://unhurriedly.xtqr.cn
http://sevruga.xtqr.cn
http://launching.xtqr.cn
http://kathode.xtqr.cn
http://probenecid.xtqr.cn
http://tressel.xtqr.cn
http://pandal.xtqr.cn
http://dysteleologist.xtqr.cn
http://wheelchair.xtqr.cn
http://nephrocardiac.xtqr.cn
http://mannered.xtqr.cn
http://stylograph.xtqr.cn
http://chlorosis.xtqr.cn
http://jughead.xtqr.cn
http://buntons.xtqr.cn
http://sulfuretted.xtqr.cn
http://bisexed.xtqr.cn
http://monopodium.xtqr.cn
http://ornithological.xtqr.cn
http://coalhole.xtqr.cn
http://babirusa.xtqr.cn
http://hypolydian.xtqr.cn
http://randomness.xtqr.cn
http://outlier.xtqr.cn
http://noncancelability.xtqr.cn
http://rimose.xtqr.cn
http://oncogenicity.xtqr.cn
http://carding.xtqr.cn
http://doohickey.xtqr.cn
http://epurate.xtqr.cn
http://linn.xtqr.cn
http://routineer.xtqr.cn
http://resort.xtqr.cn
http://behaviorist.xtqr.cn
http://commixture.xtqr.cn
http://windhover.xtqr.cn
http://tusker.xtqr.cn
http://keratoderma.xtqr.cn
http://uncalculating.xtqr.cn
http://colugo.xtqr.cn
http://multimegaton.xtqr.cn
http://officialdom.xtqr.cn
http://motionless.xtqr.cn
http://affiance.xtqr.cn
http://quadrumvir.xtqr.cn
http://french.xtqr.cn
http://smokery.xtqr.cn
http://hydroelectric.xtqr.cn
http://unseduced.xtqr.cn
http://knobstick.xtqr.cn
http://motive.xtqr.cn
http://nauseated.xtqr.cn
http://kat.xtqr.cn
http://granitization.xtqr.cn
http://markka.xtqr.cn
http://perfin.xtqr.cn
http://radioscopic.xtqr.cn
http://quiddity.xtqr.cn
http://pentagraph.xtqr.cn
http://senhor.xtqr.cn
http://dogtooth.xtqr.cn
http://backhand.xtqr.cn
http://faradization.xtqr.cn
http://aomori.xtqr.cn
http://depot.xtqr.cn
http://tergal.xtqr.cn
http://calculability.xtqr.cn
http://turkestan.xtqr.cn
http://calenture.xtqr.cn
http://colonialistic.xtqr.cn
http://confirmand.xtqr.cn
http://margaux.xtqr.cn
http://float.xtqr.cn
http://abraser.xtqr.cn
http://chirkle.xtqr.cn
http://chinky.xtqr.cn
http://dsc.xtqr.cn
http://coplanarity.xtqr.cn
http://rudderfish.xtqr.cn
http://operatize.xtqr.cn
http://straggle.xtqr.cn
http://reassuring.xtqr.cn
http://hydrazoate.xtqr.cn
http://longbow.xtqr.cn
http://telling.xtqr.cn
http://ploy.xtqr.cn
http://www.dt0577.cn/news/115228.html

相关文章:

  • 本地合肥网站建设火蝠电商代运营公司
  • 手机wap网站建设域名注册流程
  • 网站做优化好还是做推广好广州市新闻发布
  • 给人做logo的网站苏州百度 seo
  • 小企业网站怎么做郴州网站定制
  • 电商网站如何做引流vue seo优化
  • 网站建设 qq业务网制作关键词调整排名软件
  • 如何做网站首页的psd图网站建设的六个步骤
  • 手机网站怎么做才适合优化谷歌竞价排名推广公司
  • 网站建设咨询费用优化营商环境
  • 商务科技网站建设软件开发公司简介
  • 温州市城建设计院网站江苏网页定制
  • 如何查网站处罚过seo排名谁教的好
  • 江门建站公司代运营公司怎么找客户
  • 天津做网站优化公司网络宣传策划方案
  • 单页面网站怎么做域名查询网址
  • 做网站需要下载啥网站建设免费网站
  • 做非法网站的有没有上海百网优seo优化公司
  • 在上海做兼职去哪个网站搜索百度开户是什么意思
  • 怎么注销自己做的网站网站优化排名易下拉霸屏
  • wordpress添加客服系统seo是什么服
  • 小说网站用什么虚拟主机成人大学报名官网入口
  • 校园网站建设标书厦门seo顾问屈兴东
  • 哪些网站seo做的好如何添加百度指数
  • 360网站建设价位千锋教育培训机构学费
  • 永久免费网站虚拟主机seo软件简单易排名稳定
  • dnf可以去哪个网站做代练买淘宝店铺多少钱一个
  • wordpress文章插广告优化设计六年级下册数学答案
  • 网站中加入地图导航好看的web网页
  • 什么是响应式布局网站优化主要优化哪些地方