[英]Wildfly 21 – how to customize returns for Bean Validation exceptions
I've tried registering custom exception mappers in multiple ways:我尝试以多种方式注册自定义异常映射器:
@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) {
...
}
}
But all that happens is the default behaviour by the ResteasyViolationExceptionMapper.但发生的一切都是 ResteasyViolationExceptionMapper 的默认行为。 My custom ExceptionMapper is never called.
我的自定义 ExceptionMapper 永远不会被调用。 I don't know what else to try.
我不知道还能尝试什么。
I don't know why it didn't work when I first tried it, but this works我不知道为什么我第一次尝试它时它不起作用,但这有效
@Provider
public class ConstraintViolationMapper implements ExceptionMapper<ValidationException> {
@Override
public Response toResponse(ValidationException exception) {
...
}
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.