赞
踩
图片转为Base64编码后,传给其他服务,解析Base64为图片出错,对比查看后,服务接收到的Base64编码,每76个字符后会有\n。
在将图片转为Base64时,使用commons-codec包里的Base64工具类,可以避免转为Base64后换行的问题。
1.pom文件中添加如下包
<dependency>
<groupId>commons-codec</groupId>
<artifactId>commons-codec</artifactId>
<version>1.8</version>
</dependency>
2.使用Base64.encodeBase64String(参数)方法进行编码
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。