1
在我RestEasy的服務,我想在客戶端的請求返回的媒體文件,如:如何在RestEasy的服務響應指定自定義HTTP錯誤
從服務器端(tomcat的6):
@GET
@Path("/getXML/{skinId}/{key}")
@Produces("text/xml")
public Response getXMLResource(@PathParam("key") String key, @PathParam("skinId") String skinId) {
// Reading a file from disk...
return Response.ok(file, type).build();
}
而從客戶端:
final URL uri = new URL("http://localhost:8080/service/getXML");
final InputStream stream = uri.openStream();
問題:
我想返回定製HT TP錯誤(資源不存在;服務器正忙,請稍後再試)。
@GET
@Path("/getError")
@Produces("text/xml")
public Response getError() {
return Response.serverError().status(333).build();
}
但是,當我試圖訪問錯誤的方法,我得到500(!)(無論如何)內部服務器錯誤。
你們能幫我解決嗎? 在此先感謝!