java - Spring REST best practice for method types -


i building spring restfull service , have following method retrieves place object based on given zipcode:

@requestmapping(value = "/placebyzip",  method = requestmethod.get) public place getplacebyzipcode(@requestparam(value="zipcode") string zipcode)   {     place place = placeservice.placebyzip(zipcode);     return  place; } 

is best practice have return type of "place"? imagine difficult error handling?

using latest versions of spring restfull web service believe returning 'object' practise allows simplify code , specific on returning. see typing api response.

a practise error handling use controller advice utility supplied spring.

have read of:

https://spring.io/blog/2013/11/01/exception-handling-in-spring-mvc

this allows throw exceptions @ of service layers , produce nice helpful error response.


Comments

Popular posts from this blog

c++ - Difference between pre and post decrement in recursive function argument -

php - Nothing but 'run(); ' when browsing to my local project, how do I fix this? -

php - How can I echo out this array? -