zoukankan      html  css  js  c++  java
  • 微信支付二码生成办法

    引入相关pom依赖

    <!-- https://mvnrepository.com/artifact/com.google.zxing/core  生成二维码 -->
    <dependency>
        <groupId>com.google.zxing</groupId>
        <artifactId>core</artifactId>
        <version>3.3.0</version>
    </dependency>
    <dependency>
        <groupId>com.google.zxing</groupId>
        <artifactId>javase</artifactId>
        <version>3.3.0</version>
    </dependency>

    操作代码

    JSONObject jsonObject = new JSONObject();
    jsonObject.put("userName","alex");
    String s = jsonObject.toJSONString();
    System.out.println(s);

    // 定义图片宽度
    int width = 200;
    // 定义图片高度
    int height= 200;

    Map<EncodeHintType,Object> hints = new HashMap<EncodeHintType, Object>();
    hints.put(EncodeHintType.CHARACTER_SET,"UTF-8");
    BitMatrix bitMatrix = new MultiFormatWriter().encode(s, BarcodeFormat.QR_CODE,width,height,hints);

    String filePath = "D://";
    String fileName = "qrCode.jpg";

    // 定义路径对象
    Path path = FileSystems.getDefault().getPath(filePath,fileName);
    MatrixToImageWriter.writeToPath(bitMatrix,"jpg",path);

    System.out.println(path);
  • 相关阅读:
    JavaScript 消息框
    DOM事件
    修改输入框placeholder文字默认颜色-webkit-input-placeholder
    css—文字渐变色
    css—各浏览器下的背景色渐变
    $.ajax()方法详解
    使用meta实现页面的定时刷新或跳转
    python的连接mysql的安装
    django安装
    速查
  • 原文地址:https://www.cnblogs.com/leigepython/p/11444899.html
Copyright © 2011-2022 走看看