I used Restlet framework to provide the RESTful service.
I used the ResouceException the return the HTTP ERROR CODE, like 400 Bad Request, and so on.
I "new" the ResourceException(code, name, desc, uri) with the code, name and desc. I get the following output:
Bad Request (name)
period is not a number (desc)
You can get technical details here. (uri,though I didn't provide it)
Please continue your visit at our home page. (home page, I didn't provide, too)
I think the last two sentences is no use for user to correct the "bad request.".
Can I remove them? How to do? Or If I want to output sth else, how to customize the message.
Thanks a lot.
You could replace the default StatusService
with one of your own.
Extending the class and Overriding getRepresentation(Status, Request, Response)
to provide the format you would like.
this can then be set in your Application
using setStatusService(StatusService)
There may be a slightly more up to date way to do this as the method I am using has survived a few Restlet updates, now but it still works.
Update
as of restlet version 2.3.x
the method to override is toRepresentation(Status, Request, Response)