Using postman raw testing spring-boot controller failed -


here controller:

controller

here postman:

via form-data, can caseid in controller.

form-data

but raw header, can't.

raw

header

i don't know why... there wrong controller ?

please help, thanks.

edit 1:

yeah. add more

we know, springmvc bind data us, when use post request , put data in body via raw , content-type:application/json, spring still bind data? request.getinputstream() call once.

edit 2:

i found way raw.

the way

get json string.

get this

ps.

why post code image?

  1. these codes simple , needn't run.

  2. it's looks good.

here example of how retrieve data using postman , bind springmvc

 @requestmapping(value = "/user/", method = requestmethod.get)     public responseentity<list<user>> listallusers() {         list<user> users = userservice.findallusers();         if (users.isempty()) {             return new responseentity(httpstatus.no_content);             // many decide return httpstatus.not_found         }         return new responseentity<list<user>>(users, httpstatus.ok);     } 

you may refer article : spring boot rest api example


Comments

Popular posts from this blog

angular - Ionic slides - dynamically add slides before and after -

minify - Minimizing css files -

Add a dynamic header in angular 2 http provider -