I was trying to build a rest api using Spring boot 1.5.9.RELEASE and been stuck on this issue. The post request to api end points works just fine but when comes to get requests the result gets repeated. The response which the app produces for get request is
{"data":["Administrator"]}{"data":["Administrator"]}
The associated request mapping class code
@RequestMapping("/get")
public ResponseEntity getAllRoles()throws Exception{
List<Roles> roles = rolesService.getRoles();
Set<String> roleNames = new HashSet<>();
for(Roles r : roles)
roleNames.add(r.getRoleName());
return new ResponseEntity(new Response(roleNames), HttpStatus.OK);
}
The Response class
public class Response<T> {
private T data;
public Response() {}
public Response(T data) {
this.data = data;
}
public T getData() {
return data;
}
public void setData(T data) {
this.data = data;
}
}
Any ideas about how to solve the issue? Thanks in advance
/getis a very interesting choice for an endpoint. Just for giggles, change it to something else and change@RequestMappingto@GetMapping