我尝试过以多种方式注册自定义异常Map器:
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ConstraintViolationException> {
@Override
public Response toResponse(ConstraintViolationException exception) {
...
}
}
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ResteasyViolationException> {
@Override
public Response toResponse(ResteasyViolationException exception) {
...
}
}
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ValidationException> {
@Override
public Response toResponse(ValidationException exception) {
...
}
}
但所发生的只是resteasyviolationexceptionapper的默认行为。我的自定义异常apper从未被调用。我不知道还能尝试什么。
1条答案
按热度按时间tv6aics11#
我不知道为什么我第一次试的时候它不起作用,但是这个很管用