Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/date/2.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

Warning: file_get_contents(/data/phpspider/zhask/data//catemap/5/spring-mvc/2.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
Date 如何从两个不同的输入读取日期?_Date_Spring Mvc_Spring Form - Fatal编程技术网

Date 如何从两个不同的输入读取日期?

Date 如何从两个不同的输入读取日期?,date,spring-mvc,spring-form,Date,Spring Mvc,Spring Form,我将jsp上的字段呈现为两个输入,如下所示: <fmt:formatDate pattern='dd/MM/yyyy' type='date' value='${campaign.beginDate}' var="startDate"/> <form:input path="startDate" id="startDate" name="startDate" data-format="dd/MM/yyyy" type="text" value="${startDate}"/&g

我将jsp上的字段呈现为两个输入,如下所示:

<fmt:formatDate pattern='dd/MM/yyyy' type='date' value='${campaign.beginDate}' var="startDate"/>
<form:input path="startDate" id="startDate" name="startDate" data-format="dd/MM/yyyy" type="text" value="${startDate}"/>

<fmt:formatDate pattern='HH:mm:ss' type='date' value='${campaign.beginDate}' var="startTime"/>
<form:input path="startTime" id="startTime" name="startTime" data-format="hh:mm:ss" type="text" value="${startTime}"/>


现在我想将日期读入控制器中的同一个日期对象。

这很简单。使用隐藏的输入字段,该字段包含日期和时间,并在控制器中读取

例如:

 <form:hidden id="<id>" path="<path>" />

或者在提交表单之前更新隐藏字段的值


在提交表单之前,使用jQuery更新字段中的值:

$("#form-id").submit(function(event) {
    var startDate = $('#startDate).val();
    var startTime = $('#startTime).val();

    $('#startDateTime').val(<pass the date and time here>);
});
$(“#表单id”).submit(函数(事件){
var startDate=$('#startDate).val();
var startTime=$('#startTime).val();
$('#startDateTime').val();
});

如果我可以从http请求中排除startDate和startTime,那么这种情况就很酷了