验证中...
语言: Java
分类: 编程语言基础
最后更新于 2018-10-12 17:06
片段 1 片段 2
引入maven架包
原始数据 复制代码
<!--二维码-->
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>javase</artifactId>
<version>3.3.1</version>
</dependency>
<dependency>
<groupId>com.google.zxing</groupId>
<artifactId>core</artifactId>
<version>3.3.1</version>
</dependency>
生成二维码图片
原始数据 复制代码
response.setHeader("Cache-Control", "no-store");
response.setHeader("Pragma", "no-cache");
response.setDateHeader("Expires", 0);
response.setContentType("image/png");
Map<EncodeHintType, Object> hints = new HashMap<>();
hints.put(EncodeHintType.ERROR_CORRECTION, ErrorCorrectionLevel.H);
hints.put(EncodeHintType.CHARACTER_SET, "UTF-8");
hints.put(EncodeHintType.MARGIN, 0);
BitMatrix bitMatrix = new MultiFormatWriter()
.encode(wxPayNativeOrderResult.getCodeUrl(), BarcodeFormat.QR_CODE, 300, 300, hints);
MatrixToImageWriter.writeToStream(bitMatrix, "png", response.getOutputStream());

评论列表( 0 )

你可以在登录后,发表评论

搜索帮助