生成二维码图片通过流写回前台
作者:互联网
后台
/**
* @param id
* @param chuanming
* @param host
* @param response
* @Method generateQRCode
* @Author charsming
* @Version 1.0
* @Description 生成船舶二维码
* @Return void
* @Date 2021-12-30 20:51
*/
@GetMapping("/getQRCode/{id}/{chuanming}/{host}")
@ResponseBody
public void generateQRCode(@PathVariable("id") String id, @PathVariable("chuanming") String chuanming, @PathVariable("host") String host,
HttpServletResponse response) {
String qrCodeUrl = host + "/charsming/bordingShip/mobile?id=" + id + "&chuanming=" + chuanming;
try {
QrConfig qrConfig = new QrConfig(300, 300);
QrCodeUtil.generate(qrCodeUrl, qrConfig, "png", response.getOutputStream());
} catch (IOException e) {
e.printStackTrace();
}
}
js
//二维码
function resetPwd(id,chuanming) {
var host = window.location.host
layer.open({
type: 1,
title: '船舶二维码',
maxmin: true,
shadeClose: false, // 点击遮罩关闭层
content: `<img src="/charsming/shipB/getQRCode/${id}/${chuanming}/${host}">`
});
}
标签:String,chuanming,host,param,二维码,前台,流写,id 来源: https://blog.csdn.net/yuzheh521/article/details/122245246