一、首先须要准备 jquery.qrcode.js 和 jquery.jsjavascript
github地址:https://github.com/lrsjng/jquery-qrcodejava
官方文档地址:http://larsjung.de/jquery-qrcode/jquery
二、而后建立jsp页面,将js引入页面。(此处须要注意的的是顺序不能颠倒,必须是jquery.js先引入)git
<script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.min.js"></script> <script type="text/javascript" src="<%=request.getContextPath()%>/js/jquery.qrcode.min.js"></script>
三、建立一个divgithub
<div id="qrcode"></div>
四、用以下js代码生成二维码(这段代码必须在div以后)jsp
jQuery('#qrcode').qrcode("二维码的信息");
五、默认生成的二维码大小是 256×256,固然能够自定义大小spa
jQuery('#qrcode').qrcode({width: 64,height: 64,text: "二维码信息"});