1
我有这个端点:消息错误添加到响应主体泽西
@POST
@Path("login")
@Consumes(MediaType.APPLICATION_JSON)
public Response doLogin(LoginCredentials loginCredentials) {
try {
usersService.validate(loginCredentials);
return Response.ok().build();
} catch (InvalidCredentialsException e) {
return Response.status(Response.Status.UNAUTHORIZED).build();
} catch (NotAuthorizedUserException e) {
return Response.status(Response.Status.UNAUTHORIZED).build();
}
}
在UNAUTHORIZED
案件,我想将消息发送给指定具体的错误。怎么可以做到这一点?
在情况下的反应是ok
,我这样做:
回报Response.ok("Some message here").build();
那么容易!谢谢。 –