mirror of
https://gitee.com/dromara/hutool.git
synced 2025-05-02 20:02:49 +08:00
fix bug
This commit is contained in:
parent
36f7909702
commit
67aa719b3c
@ -3,7 +3,7 @@
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
# 5.4.4 (2020-09-22)
|
||||
# 5.4.4 (2020-09-23)
|
||||
|
||||
### 新特性
|
||||
* 【core 】 ServiceLoaderUtil改为使用contextClassLoader(pr#183@Gitee)
|
||||
@ -11,10 +11,13 @@
|
||||
* 【extra 】 FTP增加stat方法(issue#I1W346@Gitee)
|
||||
* 【core 】 Convert.toNumber支持类似12.2F这种形式字符串转换(issue#I1VYLJ@Gitee)
|
||||
* 【core 】 使用静态变量替换999等(issue#I1W8IB@Gitee)
|
||||
* 【core 】 URLUtil自动trim(issue#I1W803@Gitee)
|
||||
|
||||
### Bug修复
|
||||
* 【crypto 】 修复SM2验签后无法解密问题(issue#I1W0VP@Gitee)
|
||||
* 【core 】 修复新建默认TreeSet没有默认比较器导致的问题(issue#1101@Github)
|
||||
* 【core 】 修复Linux下使用Windows路径分隔符导致的解压错误(issue#I1MW0E@Gitee)
|
||||
* 【core 】 修复Word07Writer写出map问题(issue#I1W49R@Gitee)
|
||||
|
||||
-------------------------------------------------------------------------------------------------------------
|
||||
|
||||
|
@ -483,13 +483,7 @@ public class URLUtil {
|
||||
* @throws UtilException 包装URISyntaxException
|
||||
*/
|
||||
public static String getPath(String uriStr) {
|
||||
URI uri;
|
||||
try {
|
||||
uri = new URI(uriStr);
|
||||
} catch (URISyntaxException e) {
|
||||
throw new UtilException(e);
|
||||
}
|
||||
return uri.getPath();
|
||||
return toURI(uriStr).getPath();
|
||||
}
|
||||
|
||||
/**
|
||||
@ -509,7 +503,7 @@ public class URLUtil {
|
||||
String path = null;
|
||||
try {
|
||||
// URL对象的getPath方法对于包含中文或空格的问题
|
||||
path = URLUtil.toURI(url).getPath();
|
||||
path = toURI(url).getPath();
|
||||
} catch (UtilException e) {
|
||||
// ignore
|
||||
}
|
||||
@ -569,7 +563,7 @@ public class URLUtil {
|
||||
location = encode(location);
|
||||
}
|
||||
try {
|
||||
return new URI(location);
|
||||
return new URI(StrUtil.trim(location));
|
||||
} catch (URISyntaxException e) {
|
||||
throw new UtilException(e);
|
||||
}
|
||||
|
@ -1116,6 +1116,8 @@ public class ZipUtil {
|
||||
* @since 5.0.5
|
||||
*/
|
||||
private static File buildFile(File outFile, String fileName) {
|
||||
// 替换Windows路径分隔符为Linux路径分隔符,便于统一处理
|
||||
fileName = fileName.replace('\\', '/');
|
||||
if (false == FileUtil.isWindows()
|
||||
// 检查文件名中是否包含"/",不考虑以"/"结尾的情况
|
||||
&& fileName.lastIndexOf(CharUtil.SLASH, fileName.length() - 2) > 0) {
|
||||
|
@ -84,4 +84,11 @@ public class URLUtilTest {
|
||||
String encode2 = URLUtil.encodeQuery(body);
|
||||
Assert.assertEquals("366466+-+%E5%89%AF%E6%9C%AC.jpg", encode2);
|
||||
}
|
||||
|
||||
@Test
|
||||
public void getPathTest(){
|
||||
String url = " http://www.aaa.bbb/search?scope=ccc&q=ddd";
|
||||
String path = URLUtil.getPath(url);
|
||||
Assert.assertEquals("/search", path);
|
||||
}
|
||||
}
|
||||
|
@ -71,7 +71,7 @@ public class TableUtil {
|
||||
return;
|
||||
}
|
||||
|
||||
Map rowMap = null;
|
||||
Map rowMap;
|
||||
if(rowBean instanceof Map) {
|
||||
rowMap = (Map) rowBean;
|
||||
} else if (BeanUtil.isBean(rowBean.getClass())) {
|
||||
@ -79,6 +79,7 @@ public class TableUtil {
|
||||
} else {
|
||||
// 其它转为字符串默认输出
|
||||
writeRow(row, CollUtil.newArrayList(rowBean), isWriteKeyAsHead);
|
||||
return;
|
||||
}
|
||||
|
||||
writeRow(row, rowMap, isWriteKeyAsHead);
|
||||
@ -98,6 +99,7 @@ public class TableUtil {
|
||||
|
||||
if (isWriteKeyAsHead) {
|
||||
writeRow(row, rowMap.keySet());
|
||||
row = row.getTable().createRow();
|
||||
}
|
||||
writeRow(row, rowMap.values());
|
||||
}
|
||||
|
@ -1,5 +1,6 @@
|
||||
package cn.hutool.poi.word.test;
|
||||
|
||||
import cn.hutool.core.collection.CollUtil;
|
||||
import cn.hutool.core.io.FileUtil;
|
||||
import cn.hutool.core.lang.Console;
|
||||
import cn.hutool.poi.word.Word07Writer;
|
||||
@ -8,6 +9,8 @@ import org.junit.Test;
|
||||
|
||||
import java.awt.Font;
|
||||
import java.io.File;
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class WordWriterTest {
|
||||
|
||||
@ -32,4 +35,18 @@ public class WordWriterTest {
|
||||
// 关闭
|
||||
writer.close();
|
||||
}
|
||||
|
||||
@Test
|
||||
@Ignore
|
||||
public void writeTableTest(){
|
||||
final Word07Writer writer = new Word07Writer();
|
||||
Map<String, Object> map = new LinkedHashMap<>();
|
||||
map.put("姓名", "张三");
|
||||
map.put("年龄", "23");
|
||||
map.put("成绩", 88.32);
|
||||
map.put("是否合格", true);
|
||||
|
||||
writer.addTable(CollUtil.newArrayList(map));
|
||||
writer.flush(FileUtil.file("d:/test/test.docx"));
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user