When I add a date field on the jsp form I get this error, but it works fine without it.
Request
http://localhost:8080/myTasks/docrea
There are two probems:
1 the parameters (idTaskCategory, idTaskPriority, idXXX) does not match the Task
fields. (this is not the cause for your problem, but it will just not work. And when you change the names so that they match, it problem is that your request contains ids, but your Task
expect objects. So you need to make the task expect ids too, or you need to register some converter)
2 (I think that this is the problem), I expect that the date format / converter does not accept the submitted date format. Add @DateTimeFormat(pattern = "yyyy-MM-dd")
to all date fields.
I think one problem could be that you use the http method (this is correct, but not the cause)GET
. A GET Request send the parameter by using the URL query string (the stuff after the ?
).
But the total length of the URL is technical restricted by browsers, chaches, webservers.
So one cause for the problem could be, that the URL gets to long, if you have a lot of paramters or a "long" value (for example a long description).
So I would recommend to use http method POST
instead. -- And using POST
is the better verb for an Request that changes something on the server (http://www.w3.org/Protocols/rfc2616/rfc2616-sec9.html) .
A long time back I also faced this problem.
I solved it using:
@InitBinder
protected void initBinder(WebDataBinder binder) {
SimpleDateFormat dateFormat = new SimpleDateFormat("yyyy-MM-dd");
binder.registerCustomEditor(Date.class, new CustomDateEditor(
dateFormat, false));
}