我在拦截器中添加了一个授权模块,并尝试使用异常映射器抛出401状态代码,但即使它正在扫描我的异常映射器,它也不会在运行时使用它。
@Component
public class ExceptionMapper implements javax.ws.rs.ext.ExceptionMapper<Exception> {
public ExceptionMapper() {
System.out.println("true Manish= " + true);
}
@Override
public Response toResponse(Exception exception) {
System.out.println("product Manish Exception comning here");
return Response.status(Response.Status.EXPECTATION_FAILED).
entity(exception.getMessage()).
type("text/plain").
build();
}
}因此,它输出的是真正的Manish=true,但是当我的拦截器抛出异常时,它不会触发toResponse()方法
发布于 2017-01-19 09:31:28
目前,MSF4J不能映射从拦截器级别抛出的异常。它只能映射在实际服务中抛出的异常。我们希望将其增强为拥有全局异常映射器。https://github.com/wso2/msf4j/issues/327就是为此而创建的。
https://stackoverflow.com/questions/41694701
复制相似问题