In my Spring[3.0] application,
I want to submit data using jquery.ajax. Spring is interpreting this request and converting to appropriate Object. however, it is unable to parse the date attributes. How do I pass them from my JSON request to java? please help...
public class MyUser{
public String name;
public Date birth;
}
@RequestMapping("/app/saveuser")
public String save(@ModelAttribute MyUser user)
{
//User has NO date.. :(
}
Front end code...
jQuery.post("/app/saveuser",
{name:"myName", birth:new Date()},
function(data){
alert(data);
} );
开发者_运维问答
Dates cannot be bound to a command object unless you specify a PropertyEditor or a Conversion service that can read some date format (this is a limitation by design, as you cannot tell what '01/02/03' means without knowing the format); try to write some @InitBinder
method and there register a CustomDateEditor
for the format you're expecting.
精彩评论