URI-specific ExceptionMapper in JAX-RS

偶尔善良 提交于 2019-12-05 09:37:24

This is quite late answer ;-) but you can always inject the UriInfo and branch on that. So,

@Context
UriInfo uriInfo;

.....

if (matchesA(uriInfo.getAbsolutePath())) {
    // do something
}

Not sure how the URI's of your app look like, but if it is possible to split your app into two servlets or filters, then you can do it like that - i.e. have one servlet/filter serve one set of resources and include the first mapper and have the other servlet/filter serve the other set of resources and include the other mapper.

If these are custom exceptions, you can also pass Request as an argument to the exception and have just a single mapper - decide on the response based in the request uri in the mapper.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!