音乐项目

获取验证码:

将获取验证码的消息发送给前端,再由后端发给前端

html 复制代码
function getverification_code(event) {
    event.preventDefault();
    console.log('点击获取验证码按钮');

    // 获取输入元素的值
    const emailInput = document.getElementById('email');
    const emailValue = emailInput.value;
    const emailformat = /^[a-zA-Z0-9._%+-]+@[a-zA-Z0-9.-]+\.[a-zA-Z]{2,}$/;
    // 获取邮箱输入框的值
    function isValidEmail(emailValue) {
        return emailformat.test(emailValue);
    }
    if (isValidEmail(emailValue)) {
        axios.post('http://localhost:8080/song2_war_exploded/test2')
            .then(response => {
                console.log('Response:', response);
            })
            .catch(error => {
                console.error('Error:', error);
            });
        alert("验证码发送成功");
    } else {
        alert("验证码发送失败");
    }

}

注册时用户信息发送给后端传入数据库:

java 复制代码
@WebServlet("/register") // 定义Servlet的URL映射
public class RegisterController extends HttpServlet {
    //这个是序列化机制的一部分,一般都写在这,不用很管他
    private static final long serialVersionUID = 1L;

    // 处理POST请求
    protected void doPost(HttpServletRequest request, HttpServletResponse response)
            throws ServletException, IOException {

        System.out.println("9999999");

        // 获取表单提交的参数
        String username = request.getParameter("username");
        String password = request.getParameter("password");
        String email = request.getParameter("email");

        User user=new User();
        user.setUserName(username);
        user.setEmail(email);
        user.setPassword(password);

我用的是普通的的dopost方法,今天才弄明白 baseservlet 的用法,先交个总结等会再改成baseservlet方法

解决了什么问题:

1.一些前端问题,触发函数之前有bug,然后用了内关联才正常,解决方法,一点点测试的

相关推荐
松树戈15 分钟前
PostgreSQL使用LIKE右模糊没有走索引分析&验证
数据库·postgresql
文牧之21 分钟前
PostgreSQL 常用日志
运维·数据库·postgresql
TE-茶叶蛋1 小时前
Redis 原子操作
数据库·redis·缓存
Linux运维老纪1 小时前
Python文件操作及数据库交互(Python File Manipulation and Database Interaction)
linux·服务器·数据库·python·云计算·运维开发
Bruce_Liuxiaowei1 小时前
MCP Python SDK构建的**SQLite浏览器**的完整操作指南
数据库·python·sqlite
数据与人工智能律师1 小时前
正确应对监管部门的数据安全审查
大数据·网络·数据库·人工智能·区块链
2401_897930061 小时前
什么是非关系型数据库
数据库·oracle
鱼丸丶粗面1 小时前
Python 读取 txt 文件详解 with ... open()
linux·数据库·python
拾荒者.1261 小时前
设计一个关键字统计程序:利用HashMap存储关键字统计信息,对用户输入的关键字进行个数统计。
数据库·python·mysql
encoding-console2 小时前
欧拉环境(openEuler 22.03 LTS SP3)安装移动磐维数据库(PanWeiDB_V2.0-S2.0.2_B01)步骤
数据库·虚拟机·欧拉·磐维数据库