⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 xmlrequestfilter.java

📁 考勤管理系统源码
💻 JAVA
字号:
package com.wiley.compBooks.EJwithUML.BillingSystemInterface;

import java.io.*;
import java.util.HashMap;
import javax.servlet.http.HttpServletRequest;
import org.xml.sax.ContentHandler;
import org.xml.sax.ErrorHandler;
import org.xml.sax.InputSource;
import org.xml.sax.SAXException;
import org.xml.sax.XMLReader;
import org.xml.sax.helpers.XMLReaderFactory;

/**
 * This is a RequestFilter that extracts all the data from a SOAP message as
 * name/value pairs and populates CMOSRequest object.
 */
public class XMLRequestFilter
{

  /**
   */
   public XMLRequestFilter()
   {
   }

  /**
   */
   public HashMap filter(HttpServletRequest request) throws IOException, SAXException
   {
     HashMap xmlRequest = new HashMap();
     ContentHandler contentHandler = new XMLContentHandler(xmlRequest);
     ErrorHandler errorHandler = new XMLErrorHandler();
     BufferedReader xmlReader = request.getReader();
     InputSource xmlSource = new InputSource(xmlReader);
     System.out.println("XMLRequestFilter.filter()-Parsing XML File: " +
                        xmlSource + "\n");
     // Instantiate a parser
     XMLReader parser = XMLReaderFactory.createXMLReader();
     // Register the content handler
     parser.setContentHandler(contentHandler);
     // Register the error handler
     parser.setErrorHandler(errorHandler);
     // Parse the document
     parser.parse(xmlSource);
     return xmlRequest;
   }

}

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -