All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.atomscat.freeswitch.xml.parser.XmlCurlParser Maven / Gradle / Ivy

The newest version!
package com.atomscat.freeswitch.xml.parser;

import com.alibaba.fastjson.JSONObject;
import com.atomscat.freeswitch.xml.domain.XmlCurl;
import com.atomscat.freeswitch.xml.exception.ParserException;
import lombok.extern.slf4j.Slf4j;

import javax.servlet.http.HttpServletRequest;
import java.util.Enumeration;
import java.util.HashMap;
import java.util.Map;

/**
 * 

XmlCurlParser class.

* * @author : zhouhailin * @version $Id: $Id */ @Slf4j public class XmlCurlParser { private XmlCurlParser() { } /** * @param request a {@link HttpServletRequest} object. * @return a {@link XmlCurl} object. * @throws ParserException */ public static XmlCurl decodeThenParse(final HttpServletRequest request) throws ParserException { return JSONObject.parseObject(JSONObject.toJSONString(getAllRequestParam(request)), XmlCurl.class); } public static Map getAllRequestParam(final HttpServletRequest request) { Map res = new HashMap(); Enumeration temp = request.getParameterNames(); if (null != temp) { while (temp.hasMoreElements()) { String en = (String) temp.nextElement(); String value = request.getParameter(en); res.put(en, value); //如果字段的值为空,判断若值为空,则删除这个字段> if (null == res.get(en) || "".equals(res.get(en))) { res.remove(en); } } } return res; } }




© 2015 - 2025 Weber Informatics LLC | Privacy Policy