Tôi đang cố gắng để làm theo các tài liệu Jersey để cho phép một tổ chức phi-200 đáp ứng nếu một lỗi xảy ra (https://jersey.java.net/documentation/latest/representations.html#d0e3586)Jersey MessageBodyWriter không tìm thấy cho loại phương tiện truyền thông = text/plain
Mã của tôi trông giống như:
@POST
@Produces(MediaType.TEXT_PLAIN)
@Consumes(MediaType.APPLICATION_FORM_URLENCODED)
public ResponseBuilder getData(@FormParam("one") String one,@FormParam("two") String two,@FormParam("three") String three) {
if(one.isEmpty() || two.isEmpty() || three.isEmpty()) {
logger.error("Missing params for getData");
throw new WebApplicationException(501);
}
return Response.ok();
}
}
này không may mang lại các lỗi sau:
[2015-02-01T16: 13: 02.157 + 0000] [glassfish 4.1] [NGHIÊM TRỌNG] [] [org.glassfish.jersey.message.internal.WriterInterceptorExecutor ] [tid: _ThreadID = 27 _ThreadName = http-listener-1 (2)] [timeMillis: 1422807182157] [levelValue: 1000] [[ MessageBodyWriter not found for media type = text/plain, type = class org.glassfish.jersey.message.internal.OutboundJaxrsResponse $ Builder , genericType = class javax.ws.rs.core.Response $ ResponseBuilder.]]
Oh Tôi cảm thấy thật ngớ ngẩn ngay bây giờ! –
Trong trường hợp không được. Tôi trả lời trả lời. –