Jersey & Spring Boot turns non-ok response statuses to 404 -
i using jersey spring boot 1.2.5. have jersey controller (annotated @produces(mediatype.application_json)
) works fine , returns json long return ok response such as
return response.ok(dto).build();
but whenever try return custom error status such as
return response.status(status.conflict).build();
it gets turned 404 such as
<html> <head> <meta http-equiv="content-type" content="text/html; charset=utf-8"/> <title>error 404 not found</title> </head> <body> <h2>http error 404</h2> <p>problem accessing /error. reason: <pre> not found</pre> </p> <hr> <i> <small>powered jetty://</small> </i> <hr/> </body> </html>
any ideas what's going on here?
jersey expects response contain entity. if return empty map error code, error gets passed onto browser empty json object.
return response.status(status.conflict).entity(new hashmap<>()).build();
if have better solutions, please feel free comment.
Comments
Post a Comment