我有两个方法,分别解析两段接收到的xml,我确定两个方法的参数request是不一样的。方法1可正确执行,方法2报错Streamclosed。我把inputStream.close()和inputStream=null注释掉还是一样。方法如下,方法1:publicstaticMapparseXml(HttpServletRequestrequest)throwsException{//将解析结果存储在HashMap中Mapmap=newHashMap();//从request中取得输入流InputStreaminputStream=request.getInputStream();//读取输入流SAXReaderreader=newSAXReader();Documentdocument=reader.read(inputStream);...//释放资源inputStream.close();inputStream=null;returnmap;}方法2:publicstaticvoidparseScanXml(HttpServletRequestrequest)throwsException{//从request中取得输入流InputStreaminputStream=request.getInputStream();//读取输入流SAXReaderreader=newSAXReader();Documentdocument=reader.read(inputStream);//得到xml根元素Elementroot=document.getRootElement();...inputStream.close();inputStream=null;}
添加回答
举报
0/150
提交
取消