新页面的登录



html1中index.html

<a th:href="@{initGuestLogin}" class="link" > <span th:if="${ #strings.isEmpty(session.UVO.guestName)}">登录</span></a>

GustController.java

 @RequestMapping(value = "initGuestLogin", method = RequestMethod.GET)

    public String initGuestLogin(Model model, Device device) {

    log.info("客户登录界面初始化");

    GoodsForm goodsForm = new GoodsForm();

    goodsForm.setType("粮食");

    model.addAttribute("goodsForm", goodsForm);

    List<CartForm> cartList = new ArrayList<>();

    model.addAttribute("cartList", cartList);

    GuestForm guestForm = new GuestForm();

    model.addAttribute("guestForm", guestForm);

    if(device.isNormal()) {

    return "shop/login";

    } else {

    return "mobile/login";

    }

    }

login.html

<div class="container mt20 regBox ">

<form  action="guestLogin" class="form-horizontal" th:object="${guestForm}"  method="post">

  <div class="form-group">

   <label for="inputEmail3" class="col-sm-4 control-label">用户名:</label>

   <div class="col-sm-8">

    <input type="text"  name="guestId"  class="form-control" />

   </div>

  </div>

  <div class="form-group">

   <label for="inputPassword3" class="col-sm-4 control-label">密 码:</label>

   <div class="col-sm-8">

      <input type="password" name="password"  class="form-control"/>

      <i class="formInfo red">密码错误</i>

   </div>

  </div>

 

  <div class="form-group">

   <div class="col-sm-offset-4 col-sm-8">

      <div class="checkbox w300 cf"><label class="fl"><input type="checkbox"/> 记住密码</label><a href="#" class="fr link">忘记密码?</a></div>

   </div>

  </div>

  <div class="form-group">

   <div class="col-sm-offset-4 col-sm-8">

     <button type="submit" class="btnYellow yh">登 录</button>

   

   </div>

  </div>

</form>



GustController.java

@R equestMapping(value = "guestLogin", method = RequestMethod.POST)

    public String guestLogin(Model model, HttpSession session, GuestForm guestForm, Device device) {

log.info("客户登录,验证客户信息,成功后进入系统");

GuestForm result = guestService.searchGuest(guestForm);

if(result != null) {

UVO uvo = new UVO();

uvo.setGuestId(result.getGuestId());

uvo.setGuestName(result.getGuestName());

uvo.setPassword(guestForm.getPassword());

uvo.setGender(result.getGender());

uvo.setAddress(result.getAddress());

uvo.setEmail(result.getEmail());

uvo.setMobile(result.getMobile());

uvo.setQq(result.getQq());

uvo.setPhone(result.getPhone());

uvo.setZip(result.getZip());

session.setAttribute("UVO", uvo);

GoodsForm goodsForm = new GoodsForm();

    goodsForm.setType("粮食");

    model.addAttribute("goodsForm", goodsForm);

    model.addAttribute("list", goodsService.searchGoodsList(goodsForm));

    CartForm cartForm = new CartForm();

    cartForm.setGuestId(uvo.getGuestId());

    model.addAttribute("cartList", cartService.searchCartList(cartForm));

    if(device.isNormal()) {

    return "shop/index";

    } else {

    return "mobile/index";

    }

} else {

model.addAttribute("message", "用户名或密码错误!");

GoodsForm goodsForm = new GoodsForm();

    goodsForm.setType("粮食");

    model.addAttribute("goodsForm", goodsForm);

    List<CartForm> cartList = new ArrayList<>();

    model.addAttribute("cartList", cartList);

if(device.isNormal()) {

    return "shop/login";

    } else {

    return "mobile/login";

    }

}

}


转载于:https://my.oschina.net/u/2412052/blog/487490

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值