有 Java 编程相关的问题?

你可以在下面搜索框中键入要查询的问题!

java JAXRS CXF异常包装

我想向CXF(2.6.1)添加一个ExceptionMapper,它不仅传递响应代码,还以有效负载格式发送异常(我现在使用的是JSON)

@Provider
public class CustomExceptionMapper
        implements
            ExceptionMapper<MyException>
{
...
@Override
public Response toResponse(MyException mex)
{
//I need something here which can convert mex object to JSON and ship it in response
// I want this to be de-serialized on client

//the following returns the status code
return Response.status(Response.Status.BAD_REQUEST).build();
}
...
}

有办法做到这一点吗


共 (0) 个答案