HTML1 in index.html
<a th:href= "@{initguestlogin}" class= "link" > <span th:if= "${#strings. IsEmpty (session. uvo.guestname)} "> Login </span></a>
Gustcontroller.java
@RequestMapping (value = "Initguestlogin", method = Requestmethod.get)
Public String Initguestlogin (model model, device device) {
log.info ("Client Login Interface initialization");
goodsform goodsform = new Goodsform ();
goodsform.settype ("food");
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" > User name:</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" > Password:</label>
<div class= "Col-sm-8" >
<input type= "password" name= "password" class= "Form-control "/>
<i class= "FormInfo red" > Password error </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"/> Remember password & Lt;/label><a href= "#" class= "fr link" > Forgot password? </a></div>
</div>
</div>
<div class= "Form-group " >
<div class= "Col-sm-offset-4 col-sm-8" >
<button type= "Submit" class= "Btnyellow yh" > Login </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 ("Customer login, verify customer information, enter the system after success");
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 ("Food" );
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", "User name or password error!") ");
goodsform goodsform = new Goodsform ();
goodsform.settype ("Food" );
model.addattribute ("Goodsform", Goodsform );
list<cartform> cartlist = new arraylist<> ( );
model.addattribute ("Cartlist", Cartlist );
if (Device.isnormal ()) {
return "Shop/login ";
} else {
return "Mobile/login ";
}
}
}
Login for new page