I am using the following code based on having an interceptor. When check returns true I want to throw a 403 error:
@Override
public void handleMessage(Message arg0) throws Fault {
HttpServletRequest request = context.getHttpServletRequest();
if(check(request)){
// currently not working
throw "Fault";
}
I want to throw a 403 error. How do I go about doing that from this situation?
I am a little confused about how "throws fault" works.
Any help is appreciated
CXF will default the status code to 500 for a Fault, but you can set it with Fault.setStatusCode . For example
Fault fault = new Fault(new Exception("Exception message"));
fault.setStatusCode(403);
throw fault;
Have you considered throwing:
throw new javax.ws.rs.ForbiddenException();
It returns http 403.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.