How do I design a generic Response builder / RESTful Web Service using Spring MVC?
Trying to build a RESTful web service using Spring MVC. The controller should return specific Java types, but the response body must be a generic envelope. How can this be done? The following sections of code are what I have so far: Controller method: @Controller @RequestMapping(value = "/mycontroller") public class MyController { public ServiceDetails getServiceDetails() { return new ServiceDetails("MyService"); } } Response envelope: public class Response<T> { private String message; private T responseBody; } ServiceDetails code: public class ServiceDetails { private String serviceName; publ
0 upvotes
View original discussion ↗
Comments
Sign in or sign up to comment and upvote.
No comments yet.