If you are looking for /Resource/Id
and that resource does not exist, I had always though that 404 was the appropriate response. However, when returning null
from a Jersey handler, I get back a "204 No Content". I can likely work with either one, but am curious to others thoughts on this.
To answer my own next question. To get Jersey to return 404 you must throw an exception.
if (a == null)
throw new WebApplicationException(404);
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…