javascript - Angular Js post date Bad Request in Java Spring mvc -


in java spring mvc project, post object @restcontroller , object post has date property. if remove property, post works successfully. date property, returns 400 bad request. in dto date java.util.date

method in controller:

@requestmapping(value = "/users/createpetition", method = requestmethod.post) public @responsebody petitiondto addpetition(@requestbody petitionrequestdto petitiondto, model model) {   ... 

petitionrequestdto

public class petitionrequestdto {  private long userid;  private long categoryid;  private string title;  private string description;  private date initialdate;  private string address; //getters setters 

the angular js call

if ($scope.petitionform.$valid) {         $http.post(getcompletepath("users/createpetition"), json.stringify($scope.newpetition))         .success(function (petition) {          }).error(function (data, status, headers, config) {          }); 

in js date has next value: thu mar 19 2015 00:00:00 gmt-0300 (argentina standard time)

the complete json is:

"{"selectedcategory":{"id":3,"name":"plomero","description":"plomeria"},"name":"aaa","title":"bbb","description":"ccc","initialdate":"2015-03-19t03:00:00.000z","address":"asd","categoryid":3}" 

you need ensure better format in js code json date. there discussion here should consider - the "right" json date format.

once have in order need corresponding date time formatter in spring mvc able convert json date string date object - spring mvc date format form:input; , here's example.


Comments

Popular posts from this blog

Payment information shows nothing in one page checkout page magento -

tcpdump - How to check if server received packet (acknowledged) -