我有@Entity
几个java.util.Date
字段;其中两个应该是时间格式的。我需要一种接受时间的方法,最好是使用选择器来坚持到我的数据库。
例如,我尝试使用
@DateTimeFormat(pattern="hh:mm a")
private Date startTime;
伴随着这一点,以及各种添加等尝试type="time"
,
...
<label for="startTime" class="sr-only">Start</label>
<form:input path="startTime" name="startTime" placeholder="Start" /
...
...但我遇到了Bad Request
错误。
我知道这意味着什么,我只需要知道一种可靠的方法来解决它。如何可靠地接受 Spring 表单中的时间输入?
附加网络信息:
Remote Address:[::1]:8080
Request URL:http://localhost:8080/shift_create/1.html
Request Method:POST
Status Code:400 Bad Request
Response Headers
view source
Cache-Control:must-revalidate,no-cache,no-store
Content-Length:307
Content-Type:text/html; charset=ISO-8859-1
Date:Mon, 10 Aug 2015 08:37:27 GMT
Server:Jetty(9.2.8.v20150217)
Request Headers
view source
Accept:text/html,application/xhtml+xml,application/xml;q=0.9,image/webp,*/*;q=0.8
Accept-Encoding:gzip, deflate
Accept-Language:en-US,en;q=0.8
Cache-Control:max-age=0
Connection:keep-alive
Content-Length:58
Content-Type:application/x-www-form-urlencoded
Cookie:JSESSIONID=1w0rkel0w4eha96edvwq7rz1m
Host:localhost:8080
Origin:http://localhost:8080
Referer:http://localhost:8080/profile.html
Upgrade-Insecure-Requests:1
User-Agent:Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/44.0.2403.130 Safari/537.36
Form Data
view source
view URL encoded
name:ThisOne
shiftDate:08/13/2015
startTime:10:10 PM
Form data source : name=ThisOne&shiftDate=08%2F13%2F2015&startTime=10%3A10+PM