@RequestMapping("denglu")
public void denglu( Comment comment, User user,Model model,HttpSession cc, HttpServletResponse response) throws IOException {
User user1 = mapperDao.login(user);//登陆
int s=0;
if (user1!=null){
cc.setAttribute("user1",user1);//存到sesson中
s=1;
}
PrintWriter out = response.getWriter();
out.print(s);
out.flush();
out.close();
}
=-----------------------------------------------------------------------------
<script>
function login(){
var username = $("#username").val();
var password = $("#password").val();
$.post("denglu",{username:username,password:password},function(data){
if(data=="1"){
alert("登录成功")
window.location.href="zh";
}else {
alert("登录失败")
}
})
}
</script>
=======================================
<div id="flipp">登陆</div>
<div id="panelp">
<div class="row">
<div class="small-5 columns">
<label>large-10 medium-7 (100% on small)
<input type="text" placeholder="username" id="username" name="username">
</label>
</div>
</div>
<div id="myButtons" class="btn btn-info btn-sm">
//登录
<button type="submit" class="glyphicon glyphicon-ok" onclick="login()" >ok</button>
</div>