生成二维码
@ApiOperation(value = "获取注册二维码") @GetMapping("/get/user/getqrcode") public void getQrCode(HttpServletResponse response, HttpServletRequest request) throws Exception { String optimalDomain = request.getParameter("optimalDomain"); String webankAppId = request.getParameter("webankAppId"); String version = request.getParameter("version"); String nonce = request.getParameter("nonce"); String orderNo = request.getParameter("orderNo"); String faceId = request.getParameter("faceId"); String url = request.getParameter("url"); String userId = request.getParameter("userId"); String sign = request.getParameter("sign"); String from = request.getParameter("from"); String redirectType = request.getParameter("redirectType"); response.setDateHeader("Expires", 0); response.setHeader("Cache-Control", "no-store, no-cache, must-revalidate"); response.addHeader("Cache-Control", "post-check=0, pre-check=0"); response.setHeader("Pragma", "no-cache"); response.setContentType("image/jpeg"); // 生成指定url对应的二维码到文件,宽和高都是300像素 String faceUrl = "https://" + optimalDomain + "/api/web/login?webankAppId=" + webankAppId + "&version=" + version + "&nonce=" + nonce + "&orderNo=" + orderNo + "&faceId=" + faceId + "&url=" + url + "&from=" + from + "&userId=" + userId + "&sign=" + sign + "&redirectType=" + redirectType; QrCodeUtil.generate(faceUrl, 300, 300, "jpg", response.getOutputStream()); }
<div> <img src="" id="getqrcode"> </div> $($('#getqrcode').attr("src","/user/get/user/getqrcode");