Warning: file_get_contents(/data/phpspider/zhask/data//catemap/9/javascript/370.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
使用Javascript预填充字段在Spring MVC表单提交时返回NULL_Javascript_Spring_Forms_Spring Mvc - Fatal编程技术网

使用Javascript预填充字段在Spring MVC表单提交时返回NULL

使用Javascript预填充字段在Spring MVC表单提交时返回NULL,javascript,spring,forms,spring-mvc,Javascript,Spring,Forms,Spring Mvc,标题清楚地描述了我的问题 预填充的值预先输入到字段中,并按预期显示,但我猜不会传递到控制器 这里有一些关于预先填充但不起作用的字段的代码,我不知道从哪里开始 这里有两个不预先填充的变量 var fullDate = new Date() var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) :(fullDate.getMonth()+1); var curre

标题清楚地描述了我的问题

预填充的值预先输入到字段中,并按预期显示,但我猜不会传递到控制器

这里有一些关于预先填充但不起作用的字段的代码,我不知道从哪里开始

这里有两个不预先填充的变量

    var fullDate = new Date()
    var twoDigitMonth = ((fullDate.getMonth().length+1) === 1)? (fullDate.getMonth()+1) :(fullDate.getMonth()+1);
    var currentDate = fullDate.getDate() + "/" + twoDigitMonth + "/" + fullDate.getFullYear();
    $("#declarationSignature").prop("disabled",true);
    $("#declartionDate").prop("disabled",true);
    $("#declarationSignature").val($("#title").val() + " " + $("#firstName").val()+ " " + $("#lastName").val());
    $("#declartionDate").val(currentDate);
有些人调用了未与spring一起保存的数据(第三个变量)


由于禁用的属性,值未过帐


在提交时删除禁用标记解决了该问题。

避免使用禁用标记,否则不会将值提交给控制器。改用只读。@Alien谢谢,我正在寻找一个替代方法:)
var selectedLocations = JSON.parse(storedValue);
console.log("parsing selected locations")
console.log(selectedLocations )
$('#storesAppliedFor').val(selectedLocations );