本文介绍了如何抛出一个403错误的Apache CXF - Java的的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我使用基于具有拦截以下code。检查时返回true,我想抛出一个403错误:
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";
}
我想抛出一个403错误。我怎么去这样做,从这个情况呢?
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.
任何帮助是pciated AP $ P $
Any help is appreciated
推荐答案
CXF将默认状态code至500的故障,但你可以将其设置<一个href=\"http://cxf.apache.org/javadoc/latest/org/apache/cxf/interceptor/Fault.html#setStatus$c$c%28int%29\">Fault.setStatus$c$c.例如:
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;
这篇关于如何抛出一个403错误的Apache CXF - Java的的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!