Spring reads the formData object, and the value of request.getParameter () is null.

jquery code, using the formData object

var formData = new FormData();
        //formData.append("shopImg", shopImg);
        //formData.append("shopStr", JSON.stringify(shop));
        var verifyCodeActual = $("-sharpj_captcha").val();
        if (!verifyCodeActual) {
            $.toast("");
            return;
        }
        formData.append("verifyCodeActual", verifyCodeActual);

        $.ajax({
            url : (isEdit ? editShopUrl : registerShopUrl),
            type : "POST",
            data : formData,
            contentType: "application/x-www-form-urlencoded",
            cache: false,
            processData: false,
            success : function(data) {
                if (data.success) {
                    console.log(data);
                    $.toast("");
                    $("-sharpcaptcha_img").click();
                } else {
                    $.toast("");
                    console.log(data);
                    $("-sharpcaptcha_img").click();
                }
            }
        });

after successfully post to the server, the Form Data read by chrome

spring key=verifyCodeActualnull

Mar.13,2021

method 1:

 $.ajax({
        url : url,
        type : 'POST',
        data : formData,
        processData: false,
        contentType: false,
        //contentType: "application/x-www-form-urlencoded",
        cache: false,
        processData: false,
        success : function(data) {
            if (data.success) {
                    console.log(data);
                    $.toast('');
                    $('-sharpcaptcha_img').click();
                } else {
                    $.toast('');
                    console.log(data);
                    $('-sharpcaptcha_img').click();
                }    
        }
    });
springmvc(MultipartHttpServletRequest request)
request.getParameter("verifyCodeActual");

method 2:

ajaxspringmvc(@RequestParam Map<String,Object> map)map

Don't use formData to save request data, just use an object to save it.

var data = {"verifyCodeActual":verifyCodeActual};

FormData is the request format needed to upload files

MySQL Query : SELECT * FROM `codeshelper`.`v9_news` WHERE status=99 AND catid='6' ORDER BY rand() LIMIT 5
MySQL Error : Disk full (/tmp/#sql-temptable-64f5-1b3847b-2c116.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
MySQL Errno : 1021
Message : Disk full (/tmp/#sql-temptable-64f5-1b3847b-2c116.MAI); waiting for someone to free some space... (errno: 28 "No space left on device")
Need Help?