|
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
|
catch(WebApplicationException
e){ LOGGER.error("webapplicationexception:
"+e.getResponse().getStatus()); //这一行是获取status
codeInputStream
in = (InputStream) e.getResponse().getEntity();//这个输入流中包含了所有的文本信息是关于error
message的byte[]
buffer;try{ buffer= new byte[in.available()]; in
length; //打开输入流并且读取,最终将其中的内容拼成字符串 while((length
= in.read(buffer,0,buffer.length))
!= -1){ output= new String(buffer,"UTF-8"); } }catch(IOException
ex){ LOGGER.error(ex.getMessage()); }}... |
关于用 apache cxf中对于不是返回200错误的处理 ,获取错误描述文本的方法
最新推荐文章于 2021-08-14 14:59:40 发布
本文介绍在使用Apache CXF框架时遇到的问题及解决方法。针对HTTP非200状态码返回的错误信息无法直接获取的情况,提供了一种通过处理字节流来提取错误描述的具体实现方案。
460

被折叠的 条评论
为什么被折叠?



