备忘2

session的存活时间,设置

if("on".equals(auto_login)){    //自登录后一周内自动登录
    Cookie cookie01 = new Cookie("JSESSIONID",session.getId());
    Cookie cookie_autologin = new Cookie("auto_login","true");
                            
        System.out.println("JSESSIONID===="+session.getId());
    cookie01.setMaxAge(60*60*24*7);
    cookie_autologin.setMaxAge(60*60*24*7);
    response.addCookie(cookie01);
    response.addCookie(cookie_autologin);
}
View Code


网站默认的首页 index.jsp
JSP中HTML和EL表达式的结合:
<input type="text" class="form-control col-sm-8" id="username" name="username" placeholder="用户名" value="${username}" >
而不是使用${empty username?"":value="${username}"} 整体加上“”的话,就会变成一个形似value="${username}"--的字符串
<input type="checkbox" name="auto_login" style="vertical-align: text-bottom;" ${empty JSESSIONID?'':'checked'}> 自动登录

 

posted @ 2018-12-15 18:33  payn  阅读(146)  评论(0)    收藏  举报