第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時(shí)綁定郵箱和手機(jī)立即綁定
已解決430363個(gè)問題,去搜搜看,總會有你想問的

cookie保存中文亂碼問題,始終解決不了

cookie保存中文亂碼問題,始終解決不了

小蜉蝣 2015-12-26 11:35:15
<%@page import="java.net.URLEncoder"%><%@ page language="java" contentType="text/html; charset=UTF-8"? ? pageEncoding="UTF-8"%><!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01 Transitional//EN" "http://www.w3.org/TR/html4/loose.dtd"><html><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8"><title>Insert title here</title></head><body> <%? request.setCharacterEncoding("UTF-8"); response.setContentType("text/html;charset=UTF-8"); String username="",password=""; //cookie //首先判斷用戶是否選擇了登陸狀態(tài) String[] isUserCookies=request.getParameterValues("isUseCookie"); if(isUserCookies!=null&&isUserCookies.length>0) { //吧用戶名和密碼保存在cookie對象里面 username=URLEncoder.encode(request.getParameter("username"), "UTF-8"); password=URLEncoder.encode(request.getParameter("password"),"UTF-8"); Cookie usernameCookie=new Cookie("username",username); Cookie passwordCookie=new Cookie("password",password); usernameCookie.setMaxAge(864000);//設(shè)置最大生存期限為10天 passwordCookie.setMaxAge(864000); response.addCookie(usernameCookie); response.addCookie(passwordCookie); } else { Cookie[] cookies=request.getCookies(); if(cookies!=null&&cookies.length>0) { for(Cookie c:cookies) { if(c.getName().equals("username")||c.getName().equals("password")){ c.setMaxAge(0);//設(shè)置cookie立即失效 response.addCookie(c); } } } } %> <a href="users.jsp">查看用戶狀態(tài)</a></body></html>
查看完整描述

1 回答

?
靈感l(wèi)s展望

TA貢獻(xiàn)6條經(jīng)驗(yàn) 獲得超0個(gè)贊

用tomcat了么,服務(wù)器也設(shè)置下編碼

查看完整回答
反對 回復(fù) 2015-12-27
  • 1 回答
  • 0 關(guān)注
  • 2852 瀏覽

添加回答

舉報(bào)

0/150
提交
取消
微信客服

購課補(bǔ)貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號