标签:value parse dep exception artifact nbsp null span word
<!-- https://mvnrepository.com/artifact/dom4j/dom4j -->
<dependency>
<groupId>dom4j</groupId>
<artifactId>dom4j</artifactId>
<version>1.6.1</version>
</dependency>
/**
* 解析微信公众号回调xml
* @param request 请求
* @return
*/
public static Map<String,String> parseRequest(HttpServletRequest request){
Map<String,String> map=new HashMap<String,String>();
SAXReader reader=new SAXReader();
Document document= null;
try {
//读取输入流获取文档对象
document = reader.read(request.getInputStream());
//根据文档对象获取根节点
Element rootElement=document.getRootElement();
//获取根所有子节点
List<Element> elements = rootElement.elements();
for (Element e:elements) {
map.put(e.getName(),e.getStringValue());
}
} catch (DocumentException | IOException e) {
e.printStackTrace();
}
return map;
}
希望我的分享对大家有所帮助。更多学习技巧也可参阅:福网!
标签:value parse dep exception artifact nbsp null span word
原文地址:https://www.cnblogs.com/meilideni/p/13161977.html