[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. // 定义一个SringBuffer对象,用于接受参数  
  2. StringBuffer xmlBuffer = new StringBuffer();  
  3. String line = null;  
  4. // 通过request获取获取输入流  
  5. BufferedReader reader = request.getReader();  
  6. // 一次读取请求输入流的数据  
  7. while ((line = reader.readLine()) != null) {  
  8.     xmlBuffer.append(line);  
  9. }  
  10. // 将从输入流中读取到的内容转换   成字符串  
  11. String xml = xmlBuffer.toString();  
  12. // 以Dom4J开始解析XML字符串  
  13. InputStream in = new ByteArrayInputStream(xml.getBytes());  
  14. Document xmlDoc = (Document)new XPPReader().read(new ByteArrayInputStream(xml.getBytes()));  
今天在学习Ajax时后,写到
[java]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. Document xmlDoc = (Document)new XPPReader().read(new ByteArrayInputStream(xml.getBytes()));  

一直报错误,提示

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. Multiple annotations found at this line:  
  2.     - The type org.gjt.xpp.XmlPullParserException cannot be resolved. It is indirectly referenced from   
  3.      required .class files  
  4.     - The method read(InputStream) from the type XPPReader refers to the missing type XmlPullParserException  
  5.     - The type org.gjt.xpp.XmlPullParserException cannot be resolved. It is indirectly referenced from   
  6.      required .class files  
  7.     - The method read(InputStream) from the type XPPReader refers to the missing type XmlPullParserException  

异常,查了半天,并且看了源代码,原因是,找不到
[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. import org.gjt.xpp.XmlPullParserException;  
的包,于是,网上各种找,都没有结果。随后在dom4j的源代码包中找到了

[html]  view plain copy 在CODE上查看代码片 派生到我的代码片
  1. pull-parser-2.1.10.jar  
架包,于是加入,顺利解决。
Logo

GitCode 天启AI是一款由 GitCode 团队打造的智能助手,基于先进的LLM(大语言模型)与多智能体 Agent 技术构建,致力于为用户提供高效、智能、多模态的创作与开发支持。它不仅支持自然语言对话,还具备处理文件、生成 PPT、撰写分析报告、开发 Web 应用等多项能力,真正做到“一句话,让 Al帮你完成复杂任务”。

更多推荐