<body>
<%
String loginname = "";
String password = "";
Cookie cookie[] = request.getCookies();
if (cookie != null) {
for (int i = 0; i < cookie.length; i++) {
if (cookie[i].getName().equals("loginname")) {
loginname = cookie[i].getValue();
}
if (cookie[i].getName().equals("password")) {
password = cookie[i].getValue();
}
}
}
%>
<div align="center" style="margin-top:100px">
<div id="p" class="easyui-panel" title="登录" style="width:300px;height:220px;padding:10px;" align="center">
<form action="goHome" method="post">
用户名:<input type="text" name="loginname" value="<%=loginname %>"/>
密 码:<input type="password" name="password" value="<%=password %>"/>
记住账号密码:<input type="checkbox" value="yes" name="status"/><br/><br/>
<input type="submit" value="登陆"/>
</form>
<input type="button" value="注册" onclick="goDesigner()"/>
</div>
</div>
</body>
@RequestMapping(value="/goHome")
public String goHome(User user,HttpSession session,HttpServletRequest request,HttpServletResponse response){
User user2=userService.checkLogin(user);
String status=request.getParameter("status");
if(user2!=null){
session.setAttribute("user", user2);
if(status!=null&&!"".equals(status)){
if("yes".equals(status)){
Cookie cookie_userName=new Cookie("loginname",user.getLoginname());
Cookie cookie_password=new Cookie("password",user.getPassword());
cookie_userName.setMaxAge(5*60);
cookie_password.setMaxAge(5*60);
response.addCookie(cookie_userName);
response.addCookie(cookie_password);
}
}
return "home";
}else{
return "fail";
}
}