<!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>注册</title> </head> <body> <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <title>欢迎注册</title> <link href="css/register.css" rel="stylesheet"> </head> <body> <div class="form-div" id="form-div"> <div class="reg-content"> <h1>欢迎注册</h1> <span>已有帐号?</span> <a href="index2.jsp">登录</a> </div> <form id="reg-form" action="" method="post"> <table> <tr> <td>用户名</td> <td class="inputs"> <input name="username" type="text" id="username" v-model="user.username"> </td> </tr> <tr> <td>密码</td> <td class="inputs"> <input name="password" type="password" id="password" v-model="user.password"> </td> </tr> <tr> <td>验证码</td> <td class="inputs"> <input name="checkCode" type="text" id="checkCode" v-model="user.checkcode" > <img id="checkCodeImg" src="/Login/user/checkCode" > <a href="" id="changeImg" >看不清?</a> <br> </td> </tr> </table> <div class="buttons"> <input value="注 册" type="button" id="reg_btn" @click="submitForm"> </div> <br class="clear"> </form> </div> <script src="js/axios-0.18.0.js"></script> <script src="js/vue.js"></script> <script src="element-ui/lib/index.js"></script> <link rel="stylesheet" href="element-ui/lib/theme-chalk/index.css"> <script> document.getElementById("changeImg").onclick = function () { document.getElementById("checkCodeImg").src = "/Login/user/checkCode?"+new Date().getMilliseconds(); } document.getElementById("checkCodeImg").onclick = function () { document.getElementById("checkCodeImg").src = "/Login/user/checkCode?"+new Date().getMilliseconds(); } </script> <script> new Vue({ el:"#form-div", data(){ return { user:{ username:"", password:"", checkcode:"" }, } }, methods:{ submitForm(){ console.log(this.user); // 发送ajax请求,添加 var _this=this; axios({ method:"post", url:"http://localhost:8080/Login/user/register", data:_this.user }).then(function (resp) { if(resp.data == "success") { location.href = "index.html"; } else if(resp.data == "error") _this.$message.error('账号已存在'); else _this.$message.error('验证码错误'); }) } } }) </script> </body> </html>
注册界面的搭建
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 阿里最新开源QwQ-32B,效果媲美deepseek-r1满血版,部署成本又又又降低了!
· 单线程的Redis速度为什么快?
· SQL Server 2025 AI相关能力初探
· AI编程工具终极对决:字节Trae VS Cursor,谁才是开发者新宠?
· 展开说说关于C#中ORM框架的用法!