当前位置: 代码迷 >> JavaScript >> jsp界面施用cookie实现换肤
  详细解决方案

jsp界面施用cookie实现换肤

热度:99   发布时间:2012-08-24 10:00:21.0
jsp界面使用cookie实现换肤

if (request.getParameter("theme") != null) {
??Cookie cookie2 = new Cookie("formThemes", request.getParameter(
????"theme").toString());
??cookie2.setPath("/");
??//? cookie2.setDomain(host);
??cookie2.setMaxAge(33333333);
??response.addCookie(cookie2);
??request.setAttribute("formThemes",request.getParameter(
??"theme").toString());
?}else{
??//初次进入去默认的皮肤或者是cookie中已经存在的皮肤
??Cookie[] cookies = request.getCookies();
??if(cookies != null && cookies.length > 0 ){
???for(int i = 0 ; i < cookies.length ; i ++){
????Cookie cookie = (Cookie)cookies[i];
????if("formThemes".equals(cookie.getName())){
?????request.setAttribute("formThemes",cookie.getValue());
????}
???}
??} else {
???//不存在cookie,则设置默认值national
???request.setAttribute("formThemes","national");
??}
??
?}

1 楼 jveqi 2011-12-08  
小爷到此一游。O0o....。
  相关解决方案