java - How to debug requests in spring 4? -


i've got app in spring, uses spring rest , spring mvc. i've got controller on post adds comment. method looks this:

@requestmapping(method = requestmethod.post) public list<comment> addcomment(comment comment) {     return service.addcomment(comment); } 

i'm sending request of type "application/json" data set {author:"text", "text":"commenttext"}, , when i'm debugging inside of method, null values on both properties. comment model:

@entity public class comment {     @id     @generatedvalue     private long id;     private string author;     private string text;      public comment() {      }      public comment(string author, string text) {         this.author = author;         this.text = text;     }      public string getauthor() {         return author;     }      public void setauthor(string author) {         this.author = author;     }      public string gettext() {         return text;     }      public void settext(string text) {         this.text = text;     }      @override     public string tostring() {         return "comment{" +                 "id=" + id +                 ", author='" + author + '\'' +                 ", text='" + text + '\'' +                 '}';     } } 

i'm wondering how can debug, went wrong ? classic servlet, request , create comment object myself using json library jackson or gson, here i'm bit blocked, because done using annotations. ideas?

you want annotate method parameter @requestbody tell spring populate from.


Comments

Popular posts from this blog

how to insert data php javascript mysql with multiple array session 2 -

multithreading - Exception in Application constructor -

windows - CertCreateCertificateContext returns CRYPT_E_ASN1_BADTAG / 8009310b -