mirror of
https://gitee.com/chinabugotech/hutool.git
synced 2025-05-09 23:51:34 +08:00
fix code
This commit is contained in:
parent
35feac4eae
commit
8a154315fe
@ -3,14 +3,13 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 6.0.0.M1 (2022-10-09)
|
||||
# 6.0.0.M1 (2023-03-10)
|
||||
|
||||
### 计划实现
|
||||
* 【poi 】 PDF相关(基于PdfBox)
|
||||
* 【poi 】 HTML、DOCX转换相关
|
||||
* 【poi 】 Markdown相关(如HTML转换等),基于commonmark-java
|
||||
* 【db 】 增加DDL封装
|
||||
* 【poi 】 CellUtil.getCellIfMergedRegion考虑添加缓存支持,增加最大和最小范围判断,减少遍历
|
||||
* 【http 】 公共代理和SSL验证
|
||||
|
||||
### ❌不兼容特性
|
||||
|
||||
|
@ -988,7 +988,11 @@ public class XmlUtil {
|
||||
public static <T> T xmlToBean(final Node node, final Class<T> bean) {
|
||||
final Map<String, Object> map = xmlToMap(node);
|
||||
if (null != map && map.size() == 1) {
|
||||
return BeanUtil.toBean(CollUtil.get(map.values(), 0), bean);
|
||||
final String nodeName = CollUtil.getFirst(map.keySet());
|
||||
if (bean.getSimpleName().equalsIgnoreCase(nodeName)) {
|
||||
// 只有key和bean的名称匹配时才做单一对象转换
|
||||
return BeanUtil.toBean(CollUtil.get(map.values(), 0), bean);
|
||||
}
|
||||
}
|
||||
return BeanUtil.toBean(map, bean);
|
||||
}
|
||||
|
@ -351,7 +351,7 @@ public class XmlUtilTest {
|
||||
|
||||
@Test
|
||||
public void xmlStrToBeanTest(){
|
||||
final String xml = "<user><name>张三</name><age>20</age><email>zhangsan@example.com</email></user>";
|
||||
final String xml = "<userInfo><name>张三</name><age>20</age><email>zhangsan@example.com</email></userInfo>";
|
||||
final Document document = XmlUtil.readXML(xml);
|
||||
final UserInfo userInfo = XmlUtil.xmlToBean(document, UserInfo.class);
|
||||
Assert.assertEquals("张三", userInfo.getName());
|
||||
|
Loading…
x
Reference in New Issue
Block a user