Github地址:https://www.github.com/jeromeetienne/jquery-qrcode
创建一个Java WEB工程,导入js文件,新建一个jsp
jsp文件内容:
<%@ page language="java" contentType="text/html; charset=UTF-8"
pageEncoding="UTF-8"%>
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd">
<html>
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>QRCodE二维码</title>
<script type="text/javascript"
src="${pageContext.request.contextPath }/js/jquery.min.js"></script>
<script type="text/javascript"
src="${pageContext.request.contextPath }/js/jquery.qrcode.min.js"></script>
</head>
<body>
生成的二维码如下:
<br />
<div id="qrcode"></div>
<script type="text/javascript">
jQuery('#qrcode').qrcode("https://www.baidu.com");
</script>
</body>
</html>
tomacat运行,二维码如下: