I applied the REST API using the spring-boot application. All my APIs now return a JSON response for each object. This answer was used by another server, which expects all of these answers to be in the same JSON format. For instance:
All my answers should be placed in the following structure:
public class ResponseDto { private Object data; private int statusCode; private String error; private String message; }
Spring-boot is currently returning error responses in a different format. How to achieve this using a filter.
Error message format;
{ "timestamp" : 1426615606, "exception" : "org.springframework.web.bind.MissingServletRequestParameterException", "status" : 400, "error" : "Bad Request", "path" : "/welcome", "message" : "Required String parameter 'name' is not present" }
I need both the error and the successful response are in the same json structure in my entire spring-boot application
source share