注册 登录  
 加关注
   显示下一条  |  关闭
温馨提示!由于新浪微博认证机制调整,您的新浪微博帐号绑定已过期,请重新绑定!立即重新绑定新浪微博》  |  关闭

Computer Science

I Pressed My Words Here. Will You Read ?

 
 
 

日志

 
 

java实现登录验证码及验证之JSP  

2017-03-29 00:23:56|  分类: My Projects |  标签: |举报 |字号 订阅

  下载LOFTER 我的照片书  |
接上篇:java实现登录验证及验证码
login.jsp
et%@ page language="java" contentType="text/html; charset=UTF-8"
        pageEncoding="UTF-8"%>
<%@ taglib uri="http://java.sun.com/jsp/jstl/core" prefix="c"%>
<c:set var="ctx" value="${pageContext.request.contextPath }"></c:set>
<c:set var="thoughts" value="${paramValues.thoughts[0] }"></c:set>
<c:set var="thoughtsParam" value=""></c:set>
<c:set var="question" value=""></c:set>
<c:choose>
        <c:when test="${thoughts!=null}">
                <c:set var="thoughtsParam" value="&thoughts=${thoughts }&"></c:set>
                <c:set var="question" value="?"></c:set>
        </c:when>
        <c:otherwise>
                <c:set var="thoughtsParam" value=""></c:set>
                <c:set var="question" value=""></c:set>
        </c:otherwise>
</c:choose>
<!DOCTYPE html>
<html lang="en">
        <head>
                <meta charset="utf-8" />
                <title>CSSABMS(数据统计分析后台)登录</title>
                <!-- <meta name="keywords" content="" />
                <meta name="description" content="" /> -->
                <meta name="viewport" content="width=device-width, initial-scale=1.0" />
                <link href="${ctx}/template/assets/css/bootstrap.min.css" rel="stylesheet" />
                <link rel="stylesheet" href="${ctx}/template/assets/css/font-awesome.min.css" />
                <link rel="stylesheet" href="${ctx}/template/assets/font/googlefont/googlefont.css" />
                <link rel="stylesheet" href="${ctx}/template/assets/css/ace.min.css" />
                <link rel="stylesheet" href="${ctx}/template/assets/css/ace-rtl.min.css" />
        </head>

        <body class="login-layout">
                <div class="main-container">
                        <div class="main-content">
                                <div class="row">
                                        <div class="col-sm-10 col-sm-offset-1">
                                                <div class="login-container">
                                                        <div class="center">
                                                        <h1>
                                                                <i class="icon-leaf green"></i>
                                                                <span class="red">CSSABMS</span>
                                                        </h1>
                                                        <h1>
                                                                <span class="white">数据统计分析后台</span>
                                                        </h1>
                                                                <h4 class="blue">&copy; computerscience</h4>
                                                        </div>
                                                        <div class="space-6"></div>
                                                        <div class="position-relative">
                                                                <div id="login-box" class="login-box visible widget-box no-border">
                                                                        <div class="widget-body">
                                                                                <div class="widget-main">
                                                                                        <h4 class="header blue lighter bigger">
                                                                                                <i class="icon-coffee green"></i>
                                                                                                请输入您的用户名和密码
                                                                                        </h4>
                                                                                        <div class="space-6"></div>
                                                                                        <form action="${ctx}/admin/user/login${question}${thoughtsParam}" method="post">
                                                                                                <fieldset>
                                                                                                        <label class="block clearfix">
                                                                                                                <span class="block input-icon input-icon-right">
                                                                                                                        <input type="text" id="userName" name="userName" class="form-control" placeholder="用户名" />
                                                                                                                        <i class="icon-user"></i>
                                                                                                                </span>
                                                                                                        </label>
                                                                                                        <label class="block clearfix">
                                                                                                                <span class="block input-icon input-icon-right">
                                                                                                                        <input type="password" id="passWord" name="userPassword" class="form-control" placeholder="密码" />
                                                                                                                        <i class="icon-lock"></i>
                                                                                                                </span>
                                                                                                        </label>
                                                                                                        <label class="block clearfix">
                                                                                                                <span class="block input-icon input-icon-right">
                                                                                                                        <img id="imgObj"  alt="" src="${ctx}/admin/verifyCode?"/>
                                                                                                                        <a href="#" onclick="changeImg()">换一张</a>
                                                                                                                </span>
                                                                                                        </label>
                                                                                                        <label class="block clearfix">
                                                                                                                <span class="block input-icon input-icon-right">
                                                                                                                        <input type="password" id="validationCode" name="validationCode" class="form-control" placeholder="验证码" />
                                                                                                                        <i class="icon-lock"></i>
                                                                                                                        <div id="info"></div>
                                                                                                                </span>
                                                                                                        </label>
                                                                                                        <div class="space"></div>
                                                                                                        <div class="clearfix">
                                                                                                                <label class="inline">
                                                                                                                        <input type="checkbox" class="ace" />
                                                                                                                        <span class="lbl"> 记住密码</span>
                                                                                                                </label>
                                                                                                                <button type="submit" class="width-35 pull-right btn btn-sm btn-danger">
                                                                                                                        <i class="icon-key"></i>
                                                                                                                        登录
                                                                                                                </button>
                                                                                                                <button type="button" value="验证一下" onclick="isRightCode()" class="width-25 pull-right btn btn-sm btn-primary">验证一下</button>
                                                                                                        </div>
                                                                                                        <div class="space-4"><span class="label label-sm label-warning">${msg}</span> </div>
                                                                                                </fieldset>
                                                                                        </form>
                                                                        </div><!-- /widget-body -->
                                                                </div><!-- /login-box -->
                                                        </div><!-- /position-relative -->
                                                </div>
                                        </div><!-- /.col -->
                                </div><!-- /.row -->
                        </div>
                </div><!-- /.main-container -->
                <script src="${ctx}/template/assets/js/jquery-2.0.3.min.js"></script>
                <script type="text/javascript">
                        function show_box(id) {
                         jQuery('.widget-box.visible').removeClass('visible');
                         jQuery('#'+id).addClass('visible');
                        }
                </script>
                <script type="text/javascript">
                function changeImg(){
                        var imgSrc = $("#imgObj");
                        var src = imgSrc.attr("src");
                        imgSrc.attr("src",chgUrl(src));
                        clearInfo();
                        $('#validationCode').val('');
                }
                //时间戳
                //为了使每次生成图片不一致,即不让浏览器读缓存,所以需要加上时间戳
                function chgUrl(url){
                        var timestamp = (new Date()).valueOf(),
                        urlurl = url.substring(0, url.indexOf("?") > 0 ?url.indexOf("?")-1 : url.length);
                        if((url.indexOf("&")>=0)){
                                urlurl = url + "&tamp=" + timestamp;
                        }else{
                                urlurl = url + "?timestamp=" + timestamp;
                        }
                        return urlurl;
                }
                function isRightCode(){
                        clearInfo();
                        var code = $("#validationCode").val();
                        code = "c=" + code;
                        $.ajax({
                                type:"POST",
                                url:"${ctx}/admin/validateCode",
                                data:code,
                                success:callback
                        });
                }
                function callback(data){
                        $("#info").html(data);
                }
                function clearInfo(){
                        $("#info").html('');
                }
                </script>
        </body>
</html>
END
  评论这张
 
阅读(26)| 评论(0)
推荐 转载

历史上的今天

在LOFTER的更多文章

评论

<#--最新日志,群博日志--> <#--推荐日志--> <#--引用记录--> <#--博主推荐--> <#--随机阅读--> <#--首页推荐--> <#--历史上的今天--> <#--被推荐日志--> <#--上一篇,下一篇--> <#-- 热度 --> <#-- 网易新闻广告 --> <#--右边模块结构--> <#--评论模块结构--> <#--引用模块结构--> <#--博主发起的投票-->
 
 
 
 
 
 
 
 
 
 
 
 
 
 

页脚

网易公司版权所有 ©1997-2017