使用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 );