java - Return the List<myObj> returned by ResponseEntity<List> -


my rest client uses resttemplate obtain list of objects.

responseentitiy<list> res = resttemplate.postforentity(geturl(), mydto, list.class); 

now want use list returned , return list calling class. in case of string, tostring used, work around lists?

first off, if know type of elements in list, may want use parameterizedtypereference class so.

responseentity<list<myobj>> res = resttemplate.postforentity(geturl(), mydto, new parameterizedtypereference<list<myobj>>() {}); 

then if want return list can do:

return res.getbody(); 

and if care list, can do:

// postforentity returns responseentity, postforobject returns body directly. return resttemplate.postforobject(geturl(), mydto, new parameterizedtypereference<list<myobj>>() {}); 

Comments

Popular posts from this blog

javascript - Jquery show_hide, what to add in order to make the page scroll to the bottom of the hidden field once button is clicked -

javascript - Highcharts multi-color line -

javascript - Enter key does not work in search box -