原创

如何处理大量用户在网络应用程序中注册[关闭]

温馨提示:
本文最后更新于 2024年04月12日,已超过 48 天没有更新。若文章内的图片失效(无法正常加载),请留言反馈或直接联系我

Suppose a thousand people visit the register page in the web application every day and send their information to the servlet for the register. What is the best way to get data in js file (register.jsp)?

An idea that came to my mind is to consider an array and put the data entered by the user in it, for example, all the names in index zero of the array, all the lastnames in index 2 and so on. Is this idea correct? Do we need to do this in the view or should this only be handled in the controller? I have written a sample code to send the data to the view as a simple array, but I think the better idea is the one I mentioned above.

The code is:

<script type="text/javascript">
$(document).ready(function() {

    $("#register").click(function() {
        var json_data = [{
            "name": $('#firstname').val(),
            "lastname":$('#lastname').val(),
            "email":$('#email').val(),
            "password1":$('#password').val(),
            "Address":
                {
                "state":$('#state').val(),
                "country":$('#country').val(),
                "city":$('#city').val()
                }
        }];
        let data = [];
        data.push(json_data);
        $.ajax({
            url: 'RegisterController',
            type: 'POST',
            data: data,
            dataType: 'json',
            contentType: 'application/json',
            mimeType: 'application/json',
        });
    });
});

If my idea is correct, I would be grateful if you could help me in writing the code.

正文到此结束
热门推荐
本文目录