java生成二维码方法

一, jquery-qrcode方法(jsp页面写)
1,引入两个js
          jquery-3.2.1.min.js
          jquery.qrcode.min.js
2,创建web项目,在WebContent下创建js文件将上面两个复制到js下
3,相同路径下创建jsp文件夹,引入JavaScript,如下:
    <%@ page language="java" contentType="text/html; charset=GB2312"
       pageEncoding="GB2312"%>
    <!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=GB2312">
         <title>二维码</title>
   </head>
   <body>
              <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery-3.2.1.min.js"></script>
             <script type="text/javascript" src="<%=request.getContextPath() %>/js/jquery.qrcode.min.js"></script>
          <div id="qrcode"></div>
      <script type="text/javascript">
            jQuery('#qrcode').qrcode({
        width: 200,
       height: 200,
text : "http://baidu.com" 
});
    </script>
   </body>
    </html>

猜你喜欢

转载自blog.csdn.net/wjc2013481273/article/details/80813693
今日推荐