• 登录


    <body>  当中

    <!-- 登录表单 -->
    <div class="container-fluid" style="margin-top: 200px;opacity:0.75">
    <div class="row">
    <div class="col-md-4"></div>
    <div class="col-md-4">
    <div class="panel panel-default">
    <div class="panel-heading">
    用户登录
    </div>
    <div class="panel-body">
    <div class="container-fluid">
    <form id="loginFrom" class="form-horizontal">
    <div class="form-group">
    <label for="UserPhone" class="col-sm-3 control-label">账户</label>
    <div class="col-sm-9">
    <input type="text" class="form-control" id="UserPhone" name="userphone" placeholder="手机号">
    </div>
    </div>
    <div class="form-group">
    <label for="UserPassword" class="col-sm-3 control-label">密码</label>
    <div class="col-sm-9">
    <input type="password" class="form-control" id="UserPassword" name="userword" placeholder="密码">
    </div>
    </div>

    <div class="form-group">
    <div class="col-sm-6">
    <button onclick="toRegister()" type="button" class="btn btn-large btn-primary btn-block">注册</button>
    </div>
    <div class="col-sm-6">
    <button type="button" class="btn btn-large btn-primary btn-block" onclick="login()">登录</button>
    </div>
    </div>
    <div class="rem-for-agile">
    <a href="../tokjdl">快捷登录</a><br>
    </div>
    </form>
    </div>
    </div>
    </div>
    </div>
    <div class="col-md-4"></div>
    </div>
    </div>

    $("#img").click(function(){
    $(this).prop("src","../img?"+new Date().getTime())
    })

    拿数据进后台
    function login() {
    //alert(123);
    $.ajax({
    url:"../ysq/login",
    data:{userphone:$("#UserPhone").val(),userword:$("#UserPassword").val()},
    success:function(data) {
    //alert("登陆成功");
    if(data.code != 3){
    alert(data.msg);
    }else if(data.code == 3){
    alert(data.msg);
    location.href = "../toIndex2";
    }
    },
    error:function () {
    alert("登录出错了");
    }
    })
    }

    controller层

    @GetMapping("login")
    @ResponseBody
    public HashMap<String,Object> login(String userphone, String userword, HttpServletRequest request){
    HashMap<String,Object> hm = new HashMap<String,Object>();
    LoginModel loginUser = travelService.queryUserphone(userphone);
    //存id
    //request.getSession().setAttribute("user", loginUser);
    if(loginUser==null){
    hm.put("code",1);
    hm.put("msg","用户名不存在");
    }else{
    if(!loginUser.getUserword().equals(userword)){
    hm.put("code",2);
    hm.put("msg","密码不正确");
    }else{
    // redisTemplate.opsForValue().set("user_txd",loginUser.getUserId());
    request.getSession().setAttribute(request.getSession().getId(),loginUser);
    hm.put("code",3);
    hm.put("msg","登录成功");
    }
    }
    return hm;
    }

    service层

    LoginModel queryUserphone(String userphone);

    public LoginModel queryUserphone(String userphone) {

    return travelServerMapper.queryUserphone(userphone);
    }

    dao层

    LoginModel queryUserphone(String userphone);

    mapper层

    <!--登录匹配手机号-->
    <select id="queryUserphone" resultType="com.jk.model.LoginModel">
    select * from t_login where userphone = #{userphone}
    </select>

  • 相关阅读:
    Linux——端口命令
    Linux——iptables 禁止 IP和端口
    CE第9关共用
    获得程序窗体标题-FindWindowW需要的参数
    mysql ODBC win10 设置
    Work
    Pet
    Is It A Tree?
    Ice_cream's world I
    小希的迷宫
  • 原文地址:https://www.cnblogs.com/yu72732/p/12697982.html
Copyright © 2020-2023  润新知